Webhook - Response Template

I have received the following response from a weather server. However, I don’t know how to tease out the temperature and humidity using Response Template.

I would like it to return the following (which can be found in Observations a bit more than halfway through the response): 53~93~

I would prefer not to have the decimals.

Thank you in advance,
Ross

{"UNITS":{
"relative_humidity":"%","air_temp":"Fahrenheit"}
,"QC_SUMMARY":{
"QC_CHECKS_APPLIED":["sl_range_check"],
"TOTAL_OBSERVATIONS_FLAGGED":0.0,
"PERCENT_OF_TOTAL_OBSERVATIONS_FLAGGED":0.0
},
"STATION":[{
"STATUS":"ACTIVE",
"MNET_ID":"23",
"PERIOD_OF_RECORD":{
"start":"2014-02-12T00:00:00Z",
"end":"2020-05-28T17:01:00Z"
},
"ELEVATION":"325",
"NAME":"E6824 Chicago",
"STID":"E6824",
"SENSOR_VARIABLES":{
"air_temp":{"air_temp_value_1":{"period_of_record":{"start":"","end":""}}},
"relative_humidity":{"relative_humidity_value_1":{"period_of_record":{"start":"","end":""}}}},
"ELEV_DEM":"325.6",
"LONGITUDE":"-94.52267",
"STATE":"IL",
"OBSERVATIONS":{"relative_humidity_value_1":{"date_time":"2020-06-08T13:46:00Z","value":93.0},
"air_temp_value_1":{"date_time":"2020-06-08T13:46:00Z","value":53.0}},
"RESTRICTED":false,
"QC_FLAGGED":false,
"LATITUDE":"42.58375",
"TIMEZONE":"America\/Chicago",
"ID":"46894"}],
"SUMMARY":{"DATA_QUERY_TIME":"7.75003433228 ms",
"RESPONSE_CODE":1,
"RESPONSE_MESSAGE":"OK",
"METADATA_RESPONSE_TIME":"124.479055405 ms",
"DATA_PARSING_TIME":"0.246047973633 ms",
"TOTAL_DATA_TIME":"7.99798965454 ms",
"NUMBER_OF_OBJECTS":1}}

You can put that JSON into an online JSON parser and see what the path to your desired value is
e.g.
STATION.0.OBSERVATIONS.relative_humidity_value_1.value
and
STATION.0.OBSERVATIONS.air_temp_value_1.value

With that you can home in on the *handlebars" syntax to effectively get that data out.

At the moment I’m a bit short on time so I’ll leave that to you (or someone else to chime in) :wink:

2 Likes

@Ross43

This tool that @rickkas7 built is excellent for creating response templates. Simply paste in a sample of your JSON and click on elements in the formatted JSON that you want to generate templates for.

https://rickkas7.github.io/mustache/

6 Likes

Thank you ScruffR and nrobinson2000. Very helpful!

Ross