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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Updating thing properties with JSON values

Tomellache2B
14-Alexandrite

Updating thing properties with JSON values

Hi, there

 

I have converted my JSON object to string (by means of the .parse) so that I could split the values. 

Now I want to update my thing properties with the values from my JSON object.

This JSON object and the thing properties are all on one thing.

 

I only managed to update the value at [0] index. When I try index [1] or higher, it throws an error.

Could you direct me if this issue has been solved already or any suggestions on how to achieve the updating of thing properties with the respective json values?

 

Much appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
abjain
13-Aquamarine
(To:Tomellache2B)

@Tomellache2B : Please go through the documentation for working in json objects.

https://support.ptc.com/help/thingworx/platform/r9/en/index.html#page/ThingWorx/Help/Best_Practices_for_Developing_Applications/workingwithjsonobjects.html

 

So , lets suppose if you have json stored on a property 'propjson' on your thing, then you can extract a value from the json using its 'key' and store it on a property defined on your thing. Eg.

var json = me.propjson;
me.newval=json['dataChangeType'] ;

View solution in original post

1 REPLY 1
abjain
13-Aquamarine
(To:Tomellache2B)

@Tomellache2B : Please go through the documentation for working in json objects.

https://support.ptc.com/help/thingworx/platform/r9/en/index.html#page/ThingWorx/Help/Best_Practices_for_Developing_Applications/workingwithjsonobjects.html

 

So , lets suppose if you have json stored on a property 'propjson' on your thing, then you can extract a value from the json using its 'key' and store it on a property defined on your thing. Eg.

var json = me.propjson;
me.newval=json['dataChangeType'] ;

Top Tags