# \[bug\] viewParams for Perspective Embedding objects do not pass updates when key is a number

**URL:** <https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [August 28, 2021, 2:34am UTC](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402 "2021-08-28T02:34:07Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [October 3, 2021, 2:58pm UTC](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402/21 "2021-10-03T14:58:53Z")

</div>

Thanks for the follow-up.

To the drawing board to re-architect the data model 😢

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 4, 2021, 12:46am UTC](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402/22 "2021-10-04T00:46:14Z")

</div>

Why do you need `01` as a key of the object?

---

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [October 4, 2021, 3:09am UTC](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402/23 "2021-10-04T03:09:53Z")

</div>

My JSON structure is hierarchical such as plant/line/cell. I used the plant name as the key with line keys within the value. In my case, the plant, line, or cell name can be alphanumeric, but sometimes it’s numeric, like 01.

Having the ID as the key allowed a very intuitive structure and very simple parsing of the hierarchy such as: json[plant][line][cell]

Given the constraints you outlined, I’ll have to rework that structure to create an id key and move the name to be a value of that key, and then convert each level of the hierarchy to be an array of dictionaries, rather than just a hierarchical dictionary.

Hopefully I explained it ok.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 4, 2021, 9:23am UTC](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402/24 "2021-10-04T09:23:46Z")

</div>

Consider just adding an alpha prefix to make your keys: `Pxxxx`, `Lyyyy`, `Czzzz`.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 4, 2021, 2:52pm UTC](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402/25 "2021-10-04T14:52:15Z")

</div>

Well, I see why you did it like that, but I’ve never been a fan of that approach because it leaves you open to key errors. When you access your “hierarchical” dictionary, you actually have no idea what keys it has until you try to get a key out of it. I much prefer to use “standardized” dictionaries, where they always have the keys I expect, but some key could potentially have no value.

```auto
my_dict = {"plant": None, "line", None, "cell": None}

```

Accessed as `my_dict["plant"]`.

If I need to use the same structure in multiple places, I’ll actually make a more heavy-weight class to define my object, which makes things even less fragile, at the expense of extra overhead.

```auto
class MyDefinedObj:
    def __init__ (self, plant=None, line=None, cell=None):
        self.plant = plant
        self.line = line
        self.cell = cell

```

Then initialized somewhere:

```auto
from MyProjectLibrary import MyDefinedObj

x = MyDefinedObj(plant="PlantA", line=1, cell=2)
# do some stuff
return x.line

```

```auto

```

---

<div class="post-metadata">

**Author:** ![321liftoff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/321liftoff/32/27544_2.png) [@321liftoff](https://forum.inductiveautomation.com/u/321liftoff)\
**Post date:** [October 5, 2021, 3:41am UTC](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402/26 "2021-10-05T03:41:10Z")

</div>

Thanks for the suggestions, I really appreciate them.

I have some buttons on my view to select plants, lines, etc which act as filters. Having the gateway script that creates the memory tag do the heavy lifting to structure the JSON hierarchically seems that it would be more efficient, rather than having every client application need to parsing through all entries in the array when they apply a filter.

I’m an amateur of python, so maybe I’m wrong about this.

@cmallonee I understand what you are getting at regarding key validation. Fortunately for my use-case, this json structure is the single-source of truth, and the entire view is dynamically built based on it, so there isn’t a chance for a mis-matched key, because everything in the view is derived from the same information.

[Previous page](https://forum.inductiveautomation.com/t/bug-viewparams-for-perspective-embedding-objects-do-not-pass-updates-when-key-is-a-number/50402.md?page=1)
