I have a field named ("last_values") that updates every five minutes, where a whole bunch of data comes in this one field. See the example data from this field, below. I want to extract into another field, the value (21.4191) that comes after "field1". Anybody have any ideas
{"field4":{"value":5,"created_at":"2023-07-24T19:45:15Z"},"log":{"value":507,"created_at":"2023-07-24T17:03:02Z"},"field3":{"value":181.44,"created_at":"2023-07-24T19:49:59Z"},"field1":{"value":21.4191,"created_at":"2023-07-24T19:55:02Z"},"field2":{"value":55.996,"created_at":"2023-07-24T19:55:02Z"},"field5":{"value":-45,"created_at":"2023-07-24T19:50:06Z"},"wifi":{"value":"ee:55:a8:0a:40:ef,-38;fe:55:a8:0a:40:ef,-38;ee:55:a8:0a:40:bf,-57;fe:55:a8:0a:40:bf,-58;02:18:4a:8c:49:62,-61","created_at":"2023-07-24T17:07:49Z"}}
Solved! Go to Solution.
This works for me in form calculation and popup.
var dic = $feature.last_values
var dicvar = Dictionary(dic)
return dicvar.field1.value
as per your modified question, this returns the field1.value and returns as a number (21.4191)
Field Maps calculated value:
Popup:
R_
Not sure what you mean by values from field1 and field2. they are numeric, so you want to add them together or return both values as a text string?
Code below returns as a string on two lines:
var dic = '{"field4":{"value":5,"created_at":"2023-07-24T19:45:15Z"},"log":{"value":507,"created_at":"2023-07-24T17:03:02Z"},"field3":{"value":181.44,"created_at":"2023-07-24T19:49:59Z"},"field1":{"value":21.4191,"created_at":"2023-07-24T19:55:02Z"},"field2":{"value":55.996,"created_at":"2023-07-24T19:55:02Z"},"field5":{"value":-45,"created_at":"2023-07-24T19:50:06Z"},"wifi":{"value":"ee:55:a8:0a:40:ef,-38;fe:55:a8:0a:40:ef,-38;ee:55:a8:0a:40:bf,-57;fe:55:a8:0a:40:bf,-58;02:18:4a:8c:49:62,-61","created_at":"2023-07-24T17:07:49Z"}}'
var dicdata = Dictionary(dic)
var f1 = "Field 1 = " + (Text(dicdata.field1.value))
var f2 = "Field 2 = " + Text(dicdata.field2.value)
return Concatenate(f1 + TextFormatting.NewLine + f2)
Should give you an idea of how to get the values from the dictionary string.
R_
@RhettZufelt Thank you for the example. I have clarified my original post, to better describe what I am trying to do.
I am working on understanding your example - I have tried the below and got the following error:
This works for me in form calculation and popup.
var dic = $feature.last_values
var dicvar = Dictionary(dic)
return dicvar.field1.value
as per your modified question, this returns the field1.value and returns as a number (21.4191)
Field Maps calculated value:
Popup:
R_