# \[Bug\] jsonGet's parsing code concatenates list values in jsons

**URL:** <https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [April 25, 2025, 3:46am UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550 "2025-04-25T03:46:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 25, 2025, 3:46am UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/1 "2025-04-25T03:46:12Z")

</div>

Ok this feels like it should be trivial but i cannot figure out how to do it...  
say i've got something like  
`jsonGet("{item: [1,2,3,4,5]}", 'item')`

which outputs [1, 2, 3, 4, 5]. I would like to use index notation to pull out the second element of that array, per [Expression Language and Syntax | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/expression-language-and-syntax#collection-and-mapping-access). But  
`jsonGet("{item: [1,2,3,4,5]}", 'item')[1]` gives me an error\_TypeConversion for the quality (item.1 doesn't work either)!

XY problem avoidance: i'd like to set an array as a property on a component, and then have another property on that component be that array indexed by a tag -- i.e.

```python
component.customprop=[1, 2, 3, 4, 5]
component.text = toString(component.customprop[{tagPath}])

```

EDIT: The plot thickens...because `{ "valueSource": "expr", "expression": "jsonGet(\"{item: [1, 2, 3, 4, 5]}\", \u0027item\u0027)", "dataType": "StringArray", "name": "New Tag", "tagType": "AtomicTag" }`

gives me an array of length 1, whos only value is '12345'

Ok, `{ "valueSource": "expr", "expression": "jsonGet(\u0027{\"item\": [\"1\", \"2\", \"3\", \"4\", \"5\"]}\u0027, \u0027item\u0027)", "dataType": "StringArray", "name": "New Tag", "tagType": "AtomicTag" }`

Gives me `"1", "2", "3", "4", "5"` as a _single string value_ which _can't_ be correct, since it's not even valid json

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 25, 2025, 4:57am UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/2 "2025-04-25T04:57:10Z")

</div>

The actual best way to do what I want to do appears to be _runscript_ which just seems wrong

---

<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 25, 2025, 8:05am UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/3 "2025-04-25T08:05:20Z")

</div>

Why not make your custom prop an actual array ?  
Then you can just use `{your_prop}[1]` to get a specific value.

---

<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 25, 2025, 9:48am UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/4 "2025-04-25T09:48:04Z")

</div>

`jsonGet("{'item': [1, 2, 3, 4, 5]}", 'item')`  
returns `[1,2,3,4,5]`. (Note lack of spaces after commas.)

`typeOf(jsonGet("{'item': [1, 2, 3, 4, 5]}", 'item'))`  
returns "String".

If I create custom property `arr` =

```python
[
  10,
  11,
  12,
  13,
  14
]

```

then `{view.custom.arr}[2]` returns value 12.

It looks to me that the jsonGet function isn't recognising the item list / array.

Update:  
This seems overly complicated but...

```python
split(
	replace(
		replace(
			jsonGet("{'item': [11, 12, 13, 14, 15]}", 'item'),
			'[',
			''
		),
		']',
		''
	),
	','	
)[2, 0]
// returns 13

```

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 25, 2025, 2:26pm UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/5 "2025-04-25T14:26:49Z")

</div>

Would the following json work?

````python
        "type": "ia.display.label",
        "meta": {
          "name": "quartile_label"
        },
        "props": {
          "text": "Normal",
          "quartileLabels": [
            "Low",
            "Normal",
            "High",
            "Warning"
          ],
          "backgroundColors": [
            "#B3E5FC",
            "#C8E6C9",
            "#FFE0B2",
            "#FFCDD2"
          ],
          "textColors": [
            "#01579B",
            "#1B5E20",
            "#E65100",
            "#B71C1C"
          ]
        },
        "style": {
          "fontSize": "18px",
          "fontWeight": "bold",
          "padding": "10px 20px",
          "borderRadius": "4px",
          "marginTop": "20px",
          "backgroundColor": "#C8E6C9",
          "color": "#1B5E20"
        },
        "propConfig": {
          "props.text": {
            "binding": {
              "type": "expr",
              "config": {
                "expression": "this.props.quartileLabels[{[default]Expressions/Slider_Quartile}]"
              }
            }
          },
          "style.backgroundColor": {
            "binding": {
              "type": "expr",
              "config": {
                "expression": "this.props.backgroundColors[{[default]Expressions/Slider_Quartile}]"
              }
            }
          },
          "style.color": {
            "binding": {
              "type": "expr",
              "config": {
                "expression": "this.props.textColors[{[default]Expressions/Slider_Quartile}]"
              }
            }
          }
        }
      },```

EDIT, works besides some improper expressions and binding configs, which i've fixed
````

---

<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:** [April 25, 2025, 2:38pm UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/6 "2025-04-25T14:38:30Z")

</div>

`jsonGet` accepts a JSONPath as the second argument:

`jsonGet("{item: [1,2,3,4,5]}", 'item[2]')` -\> `3`

No need for anything extra.

I'm actually not sure why using the subscript outside isn't working (it goes through a totally different logic path, but should still work here) but 🤷

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 25, 2025, 2:40pm UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/7 "2025-04-25T14:40:56Z")

</div>

Huh, ok, thanks!

The outside subscript not working I'll just class as a subtle bug, then. (From some forum searches it looks like jsonGet's return type has been borked for a while)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 25, 2025, 2:46pm UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/8 "2025-04-25T14:46:27Z")

</div>

The return type of `jsonGet` depends on its input type.

In this case, you are feeding it a String that happens to be valid JSON syntax. What you get back is a String that also happens to be valid JSON syntax (`"[1, 2, 3, 4, 5]"`).

I guess the expressions can't index into a String?

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [April 25, 2025, 2:52pm UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/9 "2025-04-25T14:52:14Z")

</div>

can jsonget be passed a pure dict instead of a string in an expression? i assumed brackets would cause the parser to throw a fit

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 25, 2025, 2:53pm UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/10 "2025-04-25T14:53:58Z")

</div>

AFAIK there is no "dictionary" type recognized by the expression language. The closest thing to a JSON type in Ignition is the Document type used by the tag system, which the `jsonGet` function understands.

i.e. if you were doing this up in Tag land instead of Perspective, and you were passing `jsonGet` a reference to a Document tag's value via e.g. `{MyDocumentTag}`, the result of the operation would be a Document that was actually the extracted array, and I _do_ think the expression language can subsequently index into that.

---

<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:** [April 26, 2025, 1:14am UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/11 "2025-04-26T01:14:13Z")

</div>

Perhaps you want [jsonDecode()](https://www.automation-pros.com/toolkit/doc/utility.html#jsondecode) instead of `jsonGet()`.

---

<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 26, 2025, 10:53am UTC](https://forum.inductiveautomation.com/t/bug-jsongets-parsing-code-concatenates-list-values-in-jsons/105550/12 "2025-04-26T10:53:02Z")

</div>

Nice!

```python
jsonDecode("{'item': [10, 20, 30, 40, 50]}")
// returns `{"item": [10, 20, 30, 40, 50]}`

jsonDecode("{'item': [10, 20, 30, 40, 50]}")['item']`
// returns [10, 20, 30, 40, 50]

jsonDecode("{'item': [10, 20, 30, 40, 50]}")['item'][1]
// returns 20

```
