# AttributeError: 'com.inductiveautomation.ignition.designer.gui.tool' object has no attribute 'loads'

**URL:** <https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [July 2, 2024, 4:54pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703 "2024-07-02T16:54:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luis\_Gastao](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@Luis\_Gastao](https://forum.inductiveautomation.com/u/Luis_Gastao)\
**Post date:** [July 2, 2024, 4:54pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/1 "2024-07-02T16:54:03Z")

</div>

I am trying to run the following code on the Script Console:

```python
def removeDuplicateKeys():
	import json
	x = '{"name":"Lucca"}'
	y = json.loads(x)
	return y
	
removeDuplicateKeys()

```

## However, I get an error saying the following:

## Traceback (most recent call last): File "", line 7, in File "", line 4, in removeDuplicateKeys AttributeError: 'com.inductiveautomation.ignition.designer.gui.tool' object has no attribute 'loads'

I noticed that when i run the same exact code on a different project on the same gateway, it is able to execute properly. Any ideas?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 2, 2024, 5:25pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/2 "2024-07-02T17:25:59Z")

</div>

move the import outside of the `def`. That doesn't really explain why you would be getting this error. There seems to be some type of scope leakage going on, the error is obviously referring to the `json.loads()` function, so probably has to do with the import not occurring properly.

It's also just best practice to do imports outside of any `defs`

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 2, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/3 "2024-07-02T17:45:05Z")

</div>

Do you have a project script library named `json`?

---

<div class="post-metadata">

**Author:** ![Luis\_Gastao](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@Luis\_Gastao](https://forum.inductiveautomation.com/u/Luis_Gastao)\
**Post date:** [July 2, 2024, 5:48pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/4 "2024-07-02T17:48:27Z")

</div>

I tried that. Unfortunately, it did not fix it.

---

<div class="post-metadata">

**Author:** ![Luis\_Gastao](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@Luis\_Gastao](https://forum.inductiveautomation.com/u/Luis_Gastao)\
**Post date:** [July 2, 2024, 5:55pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/5 "2024-07-02T17:55:40Z")

</div>

yes! is there a way to call an absolute path to the python library? that way i dont need to refactor everything that is using the local json library?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 2, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/6 "2024-07-02T17:56:53Z")

</div>

Not that I'm aware of. Why not use `system.util.jsonDecode` instead of Jython's `json` builtin library?

---

<div class="post-metadata">

**Author:** ![Luis\_Gastao](https://avatars.discourse-cdn.com/v4/letter/l/f04885/32.png) [@Luis\_Gastao](https://forum.inductiveautomation.com/u/Luis_Gastao)\
**Post date:** [July 2, 2024, 6:27pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/7 "2024-07-02T18:27:32Z")

</div>

the jsonDecode does not handle well situations with a duplicate key. So i am using the json functions to remove duplicates.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 2, 2024, 6:45pm UTC](https://forum.inductiveautomation.com/t/attributeerror-com-inductiveautomation-ignition-designer-gui-tool-object-has-no-attribute-loads/92703/8 "2024-07-02T18:45:14Z")

</div>

I assume that in your script library you are importing the `json` builtin library?

If so you can try adding a loads function in that library which will simply delegate the call to the `json` builtin.

Something like:

```python
def loads(jsonString):
    return json.loads(jsonString)

```

Though honestly you should probably just rename the library and get the refactoring out of the way.

Avoid using any jython/python builtin names in the future.
