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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Convert JSON into Thing Property

LS_8369616
7-Bedrock

Convert JSON into Thing Property

Hello,

I am trying to retrieve data from a REST API of a 3DPrinter and convert it into real time information through Vuforia View.

I'm stuck when i need to get the data into a Thing Property.

I've created a genericThing and i use getJSON snippets to retrieve JSON from the printer API.

I have no problem getting the JSON from the API using getJSON and those parameters :

 

let params = {

url: "http://172.25.2.8:10800/v1/printer/nozzle1?token=6721b6ca0a4ea42f3a933e356546588e" /* STRING */,
};
// result: JSON
let result = Resources["ContentLoaderFunctions"].GetJSON(params);

 

I get this JSON :

 

{
"headers": "",
"data": {
"nozzle_cur_temp": 26,
"nozzle_tar_temp": 0,
"flow_cur_rate": 100,
"flow_tar_rate": 100
},
"status": 1
}

What i want is to define "nozzle_cur_temp" value (26) as a Thing Property that updates each time i execute the script.

Like this i can use it in Vuforia.

Thanks,

Best Regards,

ACCEPTED SOLUTION

Accepted Solutions

I've found the solution,

 

I've created properties in the thing property value.

After this line :

 

let result = Resources["ContentLoaderFunctions"].GetJSON(params);

 

I write this :

 

me.TempBuseGauche = result["data"]["nozzle_cur_temp"];
me.TarTempBuseGauche = result["data"]["nozzle_tar_temp"];

 

Hope this helps,

View solution in original post

1 REPLY 1

I've found the solution,

 

I've created properties in the thing property value.

After this line :

 

let result = Resources["ContentLoaderFunctions"].GetJSON(params);

 

I write this :

 

me.TempBuseGauche = result["data"]["nozzle_cur_temp"];
me.TarTempBuseGauche = result["data"]["nozzle_tar_temp"];

 

Hope this helps,

Announcements


Top Tags