Skip to main content
14-Alexandrite
Oct 19, 2021 12:36 PM UTC
Question

JSON key

I am trying to assign numbered key to existing JSON but it shows error as per attached screenshot.Please let me know if there is a way for the error

7 replies

24-Ruby IV
Oct 19, 2021 1:37 PM UTC

Article - "Error when pushing to JSON in ThingWorx Service": https://www.ptc.com/en/support/article/CS284117

Translate
Support
Oct 28, 2021 7:22 PM UTC

Hi @KN_9954684.

 

We tested with your code and it's working fine.  What does your input look like?

 

Regards.

 

--Sharon

Translate
22-Sapphire I
Oct 19, 2021 4:46 PM UTC

It looks like you are treating this JSON as a JSON array and are trying to add a value, I believe your syntax is incorrect.

You are trying to add the value "Mix" to array row 12345

As Vladimir points out with an array you probably would use Push, if it is just a regular object, you would create a 'node' {key:value} and add that to your JSON object.

 

Since I do all my JSON using google ... I recommend you google it 🙂

Translate
14-Alexandrite
Oct 20, 2021 4:14 AM UTC

input is not an array.It is a simple json object.

 

If we replace "12345" with any string like it works perfectly.

 

I am not sure why Thingworx is not accepting numbered string key.Please try and let me know if there is any other way

Translate
22-Sapphire I
Oct 20, 2021 11:49 AM UTC

Interesting, try using single quote see if it makes a difference or even ... "'12345'" sorry not sure what else you could try.

Translate