cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

JSON key

KN_9954684
14-Alexandrite

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 7

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

slangley
23-Emerald II
(To:VladimirN)

Hi @KN_9954684.

 

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

 

Regards.

 

--Sharon

PaiChung
22-Sapphire I
(To:KN_9954684)

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

KN_9954684
14-Alexandrite
(To:PaiChung)

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

PaiChung
22-Sapphire I
(To:KN_9954684)

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

KN_9954684
14-Alexandrite
(To:PaiChung)

It doesn't make any difference

KN_9954684
14-Alexandrite
(To:KN_9954684)

Any solution for this case?

Announcements


Top Tags