Hi I-zy
There is currently no way you can do this without writing at least a little script. Here is an example panel that pulls the "name" field out of a JSON response. If the field in the example, If I wanted to get to a specific "topping", the var field = jsonObject["name"]; would change to something like: var field = jsonObject["topping"][2]["type"]; and then your parameter would show "Sugar".
<abs contexttype="opengear" keepalive="true" style="bg#dark;">
<meta>
<params>
<param access="1" maxlength="0" name="Value I Want" oid="Value_I_Want" type="STRING" value="" widget="text"/>
</params>
</meta>
<param expand="true" height="43" left="144" oid="Value_I_Want" top="59" width="273"/>
<label height="51" left="30" name="Value I Want: " style="txt-align:east" top="56" width="110"/>
<button buttontype="push" height="49" left="426" name="Parse JSON" top="58" width="107">
<task tasktype="ogscript">var jsonString = '{\
"id": "0001", \
"type": "donut", \
"name": "Cake", \
"ppu": 0.55, \
"batters": \
{ \
"batter": \
[ \
{ "id": "1001", "type": "Regular" }, \
{ "id": "1002", "type": "Chocolate" }, \
{ "id": "1003", "type": "Blueberry" }, \
{ "id": "1004", "type": "Devil\'s Food" } \
] \
}, \
"topping": \
[ \
{ "id": "5001", "type": "None" }, \
{ "id": "5002", "type": "Glazed" }, \
{ "id": "5005", "type": "Sugar" }, \
{ "id": "5007", "type": "Powdered Sugar" }, \
{ "id": "5006", "type": "Chocolate with Sprinkles" }, \
{ "id": "5003", "type": "Chocolate" }, \
{ "id": "5004", "type": "Maple" } \
] \
} ';
function callback(resultStr)
{
if (resultStr == null) // THIS CODE RUNS IF NOTHING WAS FETCHED FROM THE WEB SERVER
{
return;
}
var jsonObject = JSON.parse(resultStr); // TRANSFORM THE RAW TEXT DATA INTO A JSON OBJECT
var field = jsonObject["name"]; // THIS IS HOW I ACCESS THE "NAME" FIELD IN THE OBJECT
params.setValue('Value_I_Want', 0, field); // THIS IS HOW I AM SETTING THE PARAMETER I WILL SEE ON SCREEN
}
//ogscript.asyncPost('http://this-is-where-my-json-is', null, callback); //USE THIS LINE TO GET YOUR REAL JSON FILE
callback(jsonString); //COMMENT THIS OUT TO STOP USING MY EXAMPLE JSON
</task>
</button>
</abs>
------------------------------
James Peltzer
Ross Video
------------------------------