Skip to main content
14-Alexandrite
October 19, 2021
Question

JSON key

  • October 19, 2021
  • 2 replies
  • 2987 views

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

2 replies

24-Ruby III
October 19, 2021

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

Support
October 28, 2021

Hi @KN_9954684.

 

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

 

Regards.

 

--Sharon

22-Sapphire I
October 19, 2021

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 🙂

14-Alexandrite
October 20, 2021

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

22-Sapphire I
October 20, 2021

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