# How to guarantee integer is parsed as string in props

**URL:** <https://forum.inductiveautomation.com/t/how-to-guarantee-integer-is-parsed-as-string-in-props/100677>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 9, 2025, 7:10pm UTC](https://forum.inductiveautomation.com/t/how-to-guarantee-integer-is-parsed-as-string-in-props/100677 "2025-01-09T19:10:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noah\_Gilgo](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@Noah\_Gilgo](https://forum.inductiveautomation.com/u/Noah_Gilgo)\
**Post date:** [January 9, 2025, 7:10pm UTC](https://forum.inductiveautomation.com/t/how-to-guarantee-integer-is-parsed-as-string-in-props/100677/1 "2025-01-09T19:10:02Z")

</div>

I have a Tree component in Perspective with a JSON structure where each subtree is labelled with its index.

 ![org tree](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/0/c0b1bd86ec84fc74fd73e0144afb690a5d215c88.png)

The `selection` parameter in the Tree component controls which subtree is clicked during the Perspective session. This parameter selects the subtree by containing the subtree's index (ex. `selection: 0/0/1/0`.)

I want to add an onStartup event to the Tree component that automatically selects the root of the Tree component by setting `selection:0`, where `0` is a string, since `selection` can only accept strings as values. However, when the event sets `selection: 0`, Ignition immediately assumes that `0` must be an integer, which throws an error on the `selection` property (`integer found, string expected.`)

How can I get the props on the Tree component to accept `0` as a string? I've tried `self.props.selection[0] = '0'` and `self.props.selection[0] = str(0)` in the onStartup script, but Ignition seems to immediately register 0 as an integer.

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [January 9, 2025, 7:18pm UTC](https://forum.inductiveautomation.com/t/how-to-guarantee-integer-is-parsed-as-string-in-props/100677/2 "2025-01-09T19:18:40Z")

</div>

I am not seeing the same issue on my end. If I add a tree with a startup script that sets `self.props.selection[0]` to either the string literal or 0 casted to a string it seems to work fine and treat the value as a string.

I only get the error you are describing when I set the value as an integer.

Just in case it is an issue that was fixed I am on version 8.1.39

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [January 10, 2025, 3:41pm UTC](https://forum.inductiveautomation.com/t/how-to-guarantee-integer-is-parsed-as-string-in-props/100677/3 "2025-01-10T15:41:30Z")

</div>

Wherever `selection` is being used, can you cast it to string there to get rid of the type error?
