But you provide no information about what this json is. Does that last entry always start with “1737504000”? If not there might be a way to do it using the implementation of JSONPATH OH provides. Someone else will need to provide that. The problem is it’s not an array so you can’t use array operations (e.g [-1]).
If I were doing this I’d either figure out a REFEX or use a JS transformation.
var parsed = JSON.parse(input);
var key = parsed.Confidence.keys()[parsed.Confidence.length-1];
parsed.Confidence[key];
I’m sure there are other ways to get the value of the last element of a map. I’m assuming the keys are returned in order. If not you need to sort the keys before getting the last one.
jwiseman
(Mr. Wiseman (OH 4.3.0 Snapshot on Pi4))
3
Thanks Rich, I can always count on you. I did make a mistake by not telling you the last value changes every day (new entry is added to the end).
so that last entry is epoch time stamp so you could calculate that and pull result based on it since it is a predicable value so tomorrow you should see the last entry as 1737590400:some value
since each one of the previous is based on GMT : day name, month name day of month , year hour : minute : second AM or PM
thus 1737504000 is converted to GMT : Wednesday, January 22, 2025 12:00:00 AM
and
Yr
Mon
Day
-
-
Hr
Min
Sec
:
:
Human date to Timestamp
Epoch timestamp: 1737590400
Timestamp in milliseconds: 1737590400000 Date and time (GMT): Thursday, January 23, 2025 12:00:00 AM
Date and time (your time zone): Wednesday, January 22, 2025 7:00:00 PM GMT-05:00