What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Read last line of JSON

Votes:

0

I am needing to read the value of the / LAST / time it encounters a JSON entry, not the first..

this is what i hav, i need to pull the value of the last time it reads "count" for exmaple.. but it appears to only read the 1st time... this may be beyond what i am capable of doing..

hope you can help.

{"success":true,"data":{"13677395":{"runtime_thermostat_summary_id":13677395,"user_id":10804,"thermostat_id":15763,"date":"2020-09-17","count":65,"sum_compressor_cool_1":1140,"sum_compressor_cool_2":0,"sum_compressor_heat_1":0,"sum_compressor_heat_2":0,"sum_auxiliary_heat_1":0,"sum_auxiliary_heat_2":0,"sum_fan":2370,"sum_humidifier":0,"sum_dehumidifier":0,"sum_ventilator":0,"sum_economizer":0,"avg_outdoor_temperature":62,"avg_outdoor_humidity":74,"min_outdoor_temperature":56.5,"max_outdoor_temperature":70.9,"avg_indoor_temperature":72.3,"avg_indoor_humidity":70,"deleted":false},"13677396":{"runtime_thermostat_summary_id":13677396,"user_id":10804,"thermostat_id":15763,"date":"2020-09-18","count":288,"sum_compressor_cool_1":1695,"sum_compressor_cool_2":0,"sum_compressor_heat_1":2985,"sum_compressor_heat_2":0,"sum_auxiliary_heat_1":0,"sum_auxiliary_heat_2":0,"sum_fan":10635,"sum_humidifier":0,"sum_dehumidifier":0,"sum_ventilator":0,"sum_economizer":0,"avg_outdoor_temperature":59.2,"avg_outdoor_humidity":78,"min_outdoor_temperature":47.6,"max_outdoor_temperature":70.8,"avg_indoor_temperature":71.4,"avg_indoor_humidity":71,"deleted":false},"13677397":{"runtime_thermostat_summary_id":13677397,"user_id":10804,"thermostat_id":15763,"date":"2020-09-19","count":287,"sum_compressor_cool_1":0,"sum_compressor_cool_2":0,"sum_compressor_heat_1":3225,"sum_compressor_heat_2":0,"sum_auxiliary_heat_1":0,"sum_auxiliary_heat_2":0,"sum_fan":8700,"sum_humidifier":0,"sum_dehumidifier":0,"sum_ventilator":0,"sum_economizer":0,"avg_outdoor_temperature":58,"avg_outdoor_humidity":73,"min_outdoor_temperature":45.6,"max_outdoor_temperature":71.1,"avg_indoor_temperature":71,"avg_indoor_humidity":70,"deleted":false},"13677398":{"runtime_thermostat_summary_id":13677398,"user_id":10804,"thermostat_id":15763,"date":"2020-09-20","count":269,"sum_compressor_cool_1":0,"sum_compressor_cool_2":0,"sum_compressor_heat_1":4965,"sum_compressor_heat_2":0,"sum_auxiliary_heat_1":0,"sum_auxiliary_heat_2":0,"sum_fan":5055,"sum_humidifier":0,"sum_dehumidifier":0,"sum_ventilator":0,"sum_economizer":0,"avg_outdoor_temperature":59.3,"avg_outdoor_humidity":70,"min_outdoor_temperature":46.2,"max_outdoor_temperature":74.4,"avg_indoor_temperature":71.6,"avg_indoor_humidity":66,"deleted":false},"13709770":{"runtime_thermostat_summary_id":13709770,"user_id":10804,"thermostat_id":15763,"date":"2020-09-21","count":246,"sum_compressor_cool_1":1680,"sum_compressor_cool_2":0,"sum_compressor_heat_1":2010,"sum_compressor_heat_2":0,"sum_auxiliary_heat_1":0,"sum_auxiliary_heat_2":0,"sum_fan":3780,"sum_humidifier":0,"sum_dehumidifier":0,"sum_ventilator":0,"sum_economizer":0,"avg_outdoor_temperature":62,"avg_outdoor_humidity":73,"min_outdoor_temperature":48.7,"max_outdoor_temperature":77.3,"avg_indoor_temperature":71.2,"avg_indoor_humidity":66,"deleted":false}}}

hvac prtg toosteepalearningcurve

Created on Sep 22, 2020 2:44:11 AM



1 Reply

Votes:

0

To get the data from the latest result provided in the JSON response, you have to get the largest id first and then get the value of the key you want.

To do so, please use the following code:

$id = (($response.data | Get-Member -MemberType NoteProperty).Name | sort)[-1]

Then , when you have the id, simply gets the value with : $response.data.$id."key"

Please, replace the word key with the key you want to get the value from. For example, you can get the value from the key "count" with: $response.data.$id.count

Created on Sep 22, 2020 2:59:42 PM by  Florian Lesage [Paessler Support]

Last change on Sep 22, 2020 3:05:28 PM by  Florian Lesage [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.