Skip to main content
4-Participant
February 5, 2022
Solved

BUG REPORT: getting a json element whose key contains only digits

  • February 5, 2022
  • 3 replies
  • 3139 views

DESCRIPTION:

Thingworx service does not complete if getting a json element whose key contains only digits.

 

STEPS TO REPRODUCE:

1. Define `test` as a JSON property of a thing
2. Run the following service

 

 

me.test = {"123": "456"}

me.test["123"]
// Java class "org.json.JSONObject" has no public instance field or method named "123"

JSON.parse(JSON.stringify(me.test))["123"]
// Works (workaround)

 

 

 

ERROR MESSAGE:

 

 

Java class "org.json.JSONObject" has no public instance field or method named "123"

 

 

 

VERSION

 9.1.5-b698

 

I'm submitting the bug report here since there is a paywall on the contact us support page and this might be a big issue since it is interpretting the text of the key of the json object as code (or at least as a literal).

Best answer by slangley

Hi @BP_9999767.

 

A fix for this issue was delivered in ThingWorx 9.4 which is now available for download.

 

Regards.

 

--Sharon

3 replies

24-Ruby III
February 7, 2022

 Hi,

 

The error you are experiencing was also discussed in the following thread - "How to convert infoTable to json?": https://community.ptc.com/t5/ThingWorx-Developers/How-to-convert-infoTable-to-json/td-p/520804 

Community Manager
February 10, 2022

Hi @BP_9999767.

 

We tested and were able to recreate the issue.  We also found that we have an open bug report on this.  I am following up for a status and will post it here once I receive more information.

 

Regards.

 

--Sharon

 

slangleyCommunity ManagerAnswer
Community Manager
June 7, 2023

Hi @BP_9999767.

 

A fix for this issue was delivered in ThingWorx 9.4 which is now available for download.

 

Regards.

 

--Sharon

16-Pearl
April 15, 2025

The issue persists when writing single tags. Assuming the same scenario as in the original post with the test properts, this most simple code will fail with the same error (has no public instance field or method named "123"):

// Fails
me.test["123"] = "456";

// Works
me.test["a123"] = "456";

 

Tested in Version 9.5.6-b1150

16-Pearl
April 22, 2025

@BennyB 

per the solution of below article,  we can use JSON.parse method to modify JSON variable.

https://www.ptc.com/en/support/article/CS404027

 

Below code worked on my local TW8.5.3. Can you double check please?

 

me.test["123"] = "456";

var t = JSON.parse(JSON.stringify(me.test));
t["111"]="223";
me.test = t;