# \<ObjectWrapper\> issue while writing the data

**URL:** <https://forum.inductiveautomation.com/t/objectwrapper-issue-while-writing-the-data/95124>\
**Category:** Ignition\
**Tags:** scripting, database, perspective\
**Created:** [August 24, 2024, 11:03pm UTC](https://forum.inductiveautomation.com/t/objectwrapper-issue-while-writing-the-data/95124 "2024-08-24T23:03:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [August 25, 2024, 12:22am UTC](https://forum.inductiveautomation.com/t/objectwrapper-issue-while-writing-the-data/95124/2 "2024-08-25T00:22:40Z")

</div>

> [@Farhan\_Basheer](#):
>
> - **Expected Format:** Dictionary
> - **Actual Format:** `ObjectWrapper` with dictionary-like content

What was the actual problem you were encountering before you attempted to coerce the types?

The bandaid solution is basically just to do what you're doing, but recursively, to flatten Perspective's faux objects into native Python objects:

> [@Function to convert json string or python dict into ObjectWrapper](https://forum.inductiveautomation.com/t/function-to-convert-json-string-or-python-dict-into-objectwrapper/32861/16):
>
> Forcing each to the expected type while traversing makes a deep copy: def sanitize\_tree(element): if hasattr(element, '\_\_iter\_\_'): if hasattr(element, 'keys'): return dict((k, sanitize\_tree(element[k])) for k in element.keys()) else: return list(sanitize\_tree(x) for x in element) return element EDIT: Got rid of the unnecessary zip() and used only one keys() iterator instead of two.

But ideally, you wouldn't have to do this at all; the objects you get _are_ dictionaries and lists, according to duck typing, so you should ideally be able to pass them through other mechanisms without correction.

---

_[View the full topic](https://forum.inductiveautomation.com/t/objectwrapper-issue-while-writing-the-data/95124)._
