# How to read Object Wrapper

**URL:** <https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [April 14, 2022, 1:32am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446 "2022-04-14T01:32:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan.marcin74](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@stefan.marcin74](https://forum.inductiveautomation.com/u/stefan.marcin74)\
**Post date:** [April 14, 2022, 1:32am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/1 "2022-04-14T01:32:26Z")

</div>

I cant seem to find a way to read objectWrapper with python. Flow is → rowData.toDict() → adding one new property → sending it to modal into button value → pushing button sends value to message handler and here I have problem reading it

I got error - Error running Page/Dashboard@C/root.onMessageReceived(self, payload): TypeError: unicode indices must be integers

payload here

```auto
	<ObjectWrapper>: {u'Shift': u'1n', u'MachineId': u'PRU1', u'qualitySize': u'13 - 0', u'Datum': u'2022-04-13', u'Quality_CheckResult': None, u'OperationId': 899L, u'ProductionOrderId': 12398955L, u'HoursSpend': 0L, u'SetterPersonalId': 0L, u'MinutesPlanned_ForOperator': None, u'isPreviousShift': 1L, u'MinutesSpend_CalculatedSinceStartOfShift': 24.55, u'Pieces_GoodCount': 0L, u'OperatorPersonalId': 1123L, u'Pieces_ScrapProcessCount': 0L, u'Note': u'', u'WorkListId': 1835485L, u'CreatedOn': 1649881413743L}

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 14, 2022, 5:57am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/2 "2022-04-14T05:57:33Z")

</div>

> [@stefan.marcin74](#):
>
> ```auto
> {
> u'Shift': u'1n', u'MachineId': u'PRU1', u'qualitySize': u'13 - 0', u'Datum': u'2022-04-13', 
> u'Quality_CheckResult': None, u'OperationId': 899L, u'ProductionOrderId': 12398955L, u'HoursSpend': 0L, 
> u'SetterPersonalId': 0L, u'MinutesPlanned_ForOperator': None, u'isPreviousShift': 1L, u'MinutesSpend_CalculatedSinceStartOfShift': 24.55, 
> u'Pieces_GoodCount': 0L, u'OperatorPersonalId': 1123L, 
> u'Pieces_ScrapProcessCount': 0L, u'Note': u'', u'WorkListId': 1835485L, u'CreatedOn': 1649881413743L
> }
> 
> ```

The only thing I can see wrong is `u'MinutesPlanned_ForOperator': None`. JSON uses `null`. Do you need to convert? You could do this with `null = None` in your code

---

<div class="post-metadata">

**Author:** ![stefan.marcin74](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@stefan.marcin74](https://forum.inductiveautomation.com/u/stefan.marcin74)\
**Post date:** [April 14, 2022, 7:39am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/3 "2022-04-14T07:39:42Z")

</div>

Hi, thanks for reply but how can I access those key values ? I dont know how to read key values. The ignition says type of this object is `<type 'unicode'>`

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 14, 2022, 7:44am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/4 "2022-04-14T07:44:00Z")

</div>

If the JSON is coming is as `payload` then you can access each item as a Python dictionary item. e.g., `payload['Shift']`.

I think the problem is that your message handler isn’t recognising the payload as valid JSON. (I’m not an expert on these matters.)

---

<div class="post-metadata">

**Author:** ![stefan.marcin74](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@stefan.marcin74](https://forum.inductiveautomation.com/u/stefan.marcin74)\
**Post date:** [April 14, 2022, 8:42am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/5 "2022-04-14T08:42:43Z")

</div>

I figured it out, I had to encode dictionary to json string, then it was saved as string, then was passed between components and then I decoded it again to dictionary.

At first I used it as dictionary but the parameter was set to string so ignition wrapped it in the object and therefore I could not decode it

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 14, 2022, 11:43am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/6 "2022-04-14T11:43:53Z")

</div>

You should not have to en/decode it to json

[https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers#ComponentMessageHandlers-PassingParametersExample](https://docs.inductiveautomation.com/display/DOC81/Component+Message+Handlers#ComponentMessageHandlers-PassingParametersExample)

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [April 14, 2022, 7:42pm UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/7 "2022-04-14T19:42:20Z")

</div>

Whenever I run across this issue, usually casting the entire payload to a dictionary type removes the object wrapper and allows for normal scripting interactions.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 15, 2022, 8:01am UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/8 "2022-04-15T08:01:12Z")

</div>

Victor is right, encoding to json shouldn’t be needed. How are you passing the payload to `sendMessage()` ?

---

<div class="post-metadata">

**Author:** ![stefan.marcin74](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@stefan.marcin74](https://forum.inductiveautomation.com/u/stefan.marcin74)\
**Post date:** [April 19, 2022, 12:59pm UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/9 "2022-04-19T12:59:21Z")

</div>

but the problem was I was sending it as a Value not as an object. We have one component from Projects which is inherited and the component there has input parameter Value, so whenever I send there the Dictionary it got wrapped, because Value != Object i think, or I am understanding something wrong ?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 19, 2022, 1:08pm UTC](https://forum.inductiveautomation.com/t/how-to-read-object-wrapper/58446/10 "2022-04-19T13:08:12Z")

</div>

> [@stefan.marcin74](#):
>
> Value != Object

if you are passing along a dict "rowData.toDict() " than it should work.  
i cant really say what your Value means or is without seeing some code.  
But you really shouldnt have to decode/encode it with json
