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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Updating thing properties with JSON values

Janicen
16-Pearl

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.

 

ACCEPTED SOLUTION

Accepted Solutions
abjain
15-Moonstone
(To:Janicen)

@Janicen : 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
15-Moonstone
(To:Janicen)

@Janicen : 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'] ;

Announcements


Top Tags