Type hints are wrong (this is an old version in my clipboard history) but code usually works. Sometimes GSON can’t handle nested types. I think Phil’s module has a method to do this as well, but assume you’re not using it in this case
@staticmethod
def unWrap(wrappedObj): # type: (WrappedObject | Sequence[WrappedObject]) -> UnwrappedObject | Sequence[UnwrappedObject]
"""Unwraps Objects to dict - Used for finnicky JSON encoding and message handlers
Example: `_system.util.unWrap(self.view.params)`
Args:
wrappedObj: WrappedObject | Sequence[WrappedObject]
Returns:
dict: UnwrappedObject | Sequence[UnwrappedObject]
"""
# return dict(wrappedObj) # shallow dict, sendRequest doesn't like
# return system.util.jsonDecode(system.util.jsonEncode(wrappedObj)) # chokes (weird types/depth limitations)
# import json
# return json.loads(json.dumps(wrappedObj)) # # chokes (weird types/depth limitations)
# https://forum.inductiveautomation.com/t/function-to-convert-json-string-or-python-dict-into-objectwrapper/32861/15
from com.inductiveautomation.ignition.common import TypeUtilities
return TypeUtilities.gsonToPy(TypeUtilities.pyToGson(wrappedObj))