05-03-2021 00:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-03-2021 00:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm basing off one of the settings for my app on the Select component which is over here in the docs.
The problem I'm having is that in the companion, I can't seem to get the text value from the setting. It's parsing the JSON into the following stringified object:
{"values":[{"name":"Calories"}],"selected":[1]}
I just want to get the "Calories" text, but any variation of JSON.parse(evt.newValue) is undefined.
I've tried JSON.parse(evt.newValue.values.name) and JSON.parse(evt.newValue.values[0].name) and nothing seems to work.
How would I get the string "Calories" from the parsed JSON?

05-03-2021 00:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-03-2021 00:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Never mind, I figured it out. This is what works:
data = JSON.parse(JSON.stringify(JSON.parse(evt.newValue).values[0].name));

05-24-2021 07:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-24-2021 07:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I don't think you need to double parse it.
JSON.parse(evt.newValue).values[0].name

