# JSON import bug

**URL:** <https://forum.inductiveautomation.com/t/json-import-bug/84597>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [January 22, 2024, 10:55pm UTC](https://forum.inductiveautomation.com/t/json-import-bug/84597 "2024-01-22T22:55:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@Daniel\_Webb](https://forum.inductiveautomation.com/u/Daniel_Webb)\
**Post date:** [January 22, 2024, 10:55pm UTC](https://forum.inductiveautomation.com/t/json-import-bug/84597/1 "2024-01-22T22:55:57Z")

</div>

Ignition 8.1.28 (b2023060110)  
Script in button Event Handlers -\> action -\> actionPerformed:

```auto
import json
json.dumps({'a': 'test'})

```

Pushing button results in:

```auto
16:51:54.818 [AWT-EventQueue-0] ERROR com.inductiveautomation.ignition.client.util.gui.ErrorUtil - <HTML>Error executing script for event:&nbsp;<code><b>actionPerformed</b></code><BR>on component:&nbsp;<code><b>TestButton 1</b></code>.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
  File "<event:actionPerformed>", line 1, in <module>
  File "C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\ __init__.py", line 108, in <module>
    from .decoder import JSONDecoder
  File "C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\decoder.py", line 24, in <module>
    NaN, PosInf, NegInf = _floatconstants()
  File "C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\decoder.py", line 18, in _floatconstants
    _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
  File "C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\encodings\ __init__.py", line 142, in search_function
    raise CodecRegistryError,\
encodings.CodecRegistryError: incompatible codecs in module "encodings.hex_codec" (C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\encodings\hex_codec.py)

	at org.python.core.PyException.doRaise(PyException.java:211)
	at org.python.core.Py.makeException(Py.java:1638)
	at org.python.core.Py.makeException(Py.java:1642)
	at encodings$py.search_function$3(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\encodings\ __init__.py:164)
	at encodings$py.call_function(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\encodings\ __init__.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
	at org.python.core.PyFunction. __call__ (PyFunction.java:416)
	at org.python.core.PyFunction. __call__ (PyFunction.java:411)
	at org.python.core.codecs$CodecState.lookup(codecs.java:1706)
	at org.python.core.codecs.lookup(codecs.java:58)
	at org.python.core.codecs.decode(codecs.java:98)
	at org.python.core.PyString.decode(PyString.java:4015)
	at org.python.core.PyString.str_decode(PyString.java:4023)
	at org.python.core.PyString$str_decode_exposer. __call__ (Unknown Source)
	at org.python.core.PyObject. __call__ (PyObject.java:461)
	at org.python.core.PyObject. __call__ (PyObject.java:465)
	at json.decoder$py._floatconstants$1(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\decoder.py:22)
	at json.decoder$py.call_function(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\decoder.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyBaseCode.call(PyBaseCode.java:119)
	at org.python.core.PyFunction. __call__ (PyFunction.java:406)
	at json.decoder$py.f$0(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\decoder.py:273)
	at json.decoder$py.call_function(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\decoder.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.imp.createFromCode(imp.java:630)
	at org.python.core.imp.createFromPyClass(imp.java:312)
	at org.python.core.imp.createFromPyClass(imp.java:255)
	at org.python.core.imp.loadFromSource(imp.java:929)
	at org.python.core.imp.find_module(imp.java:769)
	at org.python.core.PyModule.findSubModule(PyModule.java:140)
	at org.python.core.PyModule.impAttr(PyModule.java:107)
	at org.python.core.imp.import_next(imp.java:1161)
	at org.python.core.imp.import_module_level(imp.java:1350)
	at org.python.core.imp.importName(imp.java:1528)
	at org.python.core.ImportFunction. __call__ ( __builtin__.java:1285)
	at org.python.core.PyObject. __call__ (PyObject.java:433)
	at org.python.core. __builtin__. __import__ ( __builtin__.java:1232)
	at org.python.core.imp.importFromAs(imp.java:1620)
	at org.python.core.imp.importFrom(imp.java:1595)
	at json$py.f$0(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\ __init__.py:293)
	at json$py.call_function(C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\json\ __init__.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.imp.createFromCode(imp.java:630)
	at org.python.core.imp.createFromPyClass(imp.java:312)
	at org.python.core.imp.createFromPyClass(imp.java:255)
	at org.python.core.imp.loadFromSource(imp.java:929)
	at org.python.core.imp.find_module(imp.java:769)
	at org.python.core.imp.import_next(imp.java:1158)
	at org.python.core.imp.import_module_level(imp.java:1350)
	at org.python.core.imp.importName(imp.java:1528)
	at org.python.core.ImportFunction. __call__ ( __builtin__.java:1285)
	at org.python.core.PyObject. __call__ (PyObject.java:433)
	at org.python.core. __builtin__. __import__ ( __builtin__.java:1232)
	at org.python.core.imp.importOne(imp.java:1547)
	at org.python.pycode._pyx27.f$0(<event:actionPerformed>:2)
	at org.python.pycode._pyx27.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:803)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:207)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:300)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy64.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.python.core.PyException: encodings.CodecRegistryError: incompatible codecs in module "encodings.hex_codec" (C:\Users\aedmw\.ignition\cache\gwlocalhost_8088\C0\pylib\encodings\hex_codec.py)
	... 102 common frames omitted

```

---

<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:** [January 22, 2024, 11:00pm UTC](https://forum.inductiveautomation.com/t/json-import-bug/84597/2 "2024-01-22T23:00:13Z")

</div>

This is fixed in 8.1.36.

---

<div class="post-metadata">

**Author:** ![Daniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@Daniel\_Webb](https://forum.inductiveautomation.com/u/Daniel_Webb)\
**Post date:** [January 23, 2024, 6:11pm UTC](https://forum.inductiveautomation.com/t/json-import-bug/84597/3 "2024-01-23T18:11:25Z")

</div>

Is there a simple fix, like a diff of the pylib json files? I don't have administrative control of the Ignition servers I use and it is a lot of effort to upgrade versions because of Large Corporate Inertia.

---

<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:** [January 23, 2024, 6:16pm UTC](https://forum.inductiveautomation.com/t/json-import-bug/84597/4 "2024-01-23T18:16:54Z")

</div>

Actually, yes, in this case it's an easy fix - patch your `codecs.py` file in the `pylib` directory on your gateway to make the `Codec` class a "new-style" class.  
That is, change the file like this:

```diff
@@ -89,7 +89,7 @@
     def __repr__ (self):
         return "<%s.%s object for encoding %s at 0x%x>" % (self. __class__. __module__ , self. __class__. __name__ , self.name, id(self))
 
-class Codec:
+class Codec(object):
 
     """ Defines the interface for stateless encoders/decoders.

```

Exact line numbers will vary a little bit depending on what version of Ignition your system started out on.  
Making that change on the gateway's filesystem should automatically disseminate changes to your designers and clients.

See [jython 2.7.x: CodecRegistryError during attempt to use 'json' or 'codecs' module · Issue #96 · jython/jython · GitHub](https://github.com/jython/jython/issues/96) for more details.

---

<div class="post-metadata">

**Author:** ![Daniel\_Webb](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@Daniel\_Webb](https://forum.inductiveautomation.com/u/Daniel_Webb)\
**Post date:** [January 23, 2024, 8:38pm UTC](https://forum.inductiveautomation.com/t/json-import-bug/84597/5 "2024-01-23T20:38:21Z")

</div>

Thanks so much! Worked like a charm.
