# Function to convert json string or python dict into ObjectWrapper

**URL:** <https://forum.inductiveautomation.com/t/function-to-convert-json-string-or-python-dict-into-objectwrapper/32861>\
**Category:** Ignition\
**Created:** [March 5, 2020, 10:45pm UTC](https://forum.inductiveautomation.com/t/function-to-convert-json-string-or-python-dict-into-objectwrapper/32861 "2020-03-05T22:45:39Z")\
**Posts on this page:** 1\
**Showing post:** 15

<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:** [May 5, 2021, 5:07pm UTC](https://forum.inductiveautomation.com/t/function-to-convert-json-string-or-python-dict-into-objectwrapper/32861/15 "2021-05-05T17:07:47Z")

</div>

Oh, right. The builtin JSON function is a little weird. Either of these seem to work:

```auto
	import json
	from java.util import Date
	
	class IgnitionEncoder(json.JSONEncoder):
		def default(self, obj):
			if isinstance(obj, Date):
				return obj.time
			elif hasattr(obj, "keys"):
				return dict(obj)
			elif hasattr(obj, " __iter__"):
				return list(obj)
			return json.JSONEncoder.default(self, obj)
	
	j = json.dumps(self.custom.controlAccess, cls=IgnitionEncoder, indent=4)
	system.perspective.print(j)

```

```auto
	from com.inductiveautomation.ignition.common import TypeUtilities
	system.perspective.print(TypeUtilities.gsonToPy(TypeUtilities.pyToGson(self.custom.controlAccess)))

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/function-to-convert-json-string-or-python-dict-into-objectwrapper/32861)._
