JSONPath Transformation get string not number

I’m getting some data via HTTP Binding and because json is returned I’m trying to get a temperature as a number using JSONPath Transformation.

The HTTP server is returning the following string:
{“software_version”: “NRZ-2017-099”, “age”:“5”, “sensordatavalues”:[{“value_type”:“SDS_P1”,“value”:“49.50”},{“value_type”:“SDS_P2”,“value”:“27.90”},{“value_type”:“BME280_temperature”,“value”:“8.60”},{“value_type”:“BME280_humidity”,“value”:“72.96”},{“value_type”:“BME280_pressure”,“value”:“93340.02”},{“value_type”:“samples”,“value”:“607281”},{“value_type”:“min_micro”,“value”:“233”},{“value_type”:“max_micro”,“value”:“26572”},{“value_type”:“signal”,“value”:"-77"}]}

I’m needing the BME280 Temperature so I’m having the item that does not work:
Number air1_temp { http="<[air1:10000:JSONPATH($.sensordatavalues[?(@.value_type==‘BME280_temperature’)].value)]" }

Then I figure out that the JSONPath Transformation is returning a sting not a number so if I changed the item to string and this is what I’m getting:
2017-11-08 00:41:33.781 [ItemStateChangedEvent ] - air1_temp changed from [“8.70”] to [“8.60”]

So how can I change the JSONPath in order to get only the number 8.60 but not [“8.60”]


@ddragoev you need two items one to save the string and one to hold the converted number, use a rule for that.

have a look at this discussion

Thank you for the update Josar. I’ve change a little but the rule as the string is [“8.60”] so now I have:

String air1_temp_s { http="<[air1:60000:JSONPATH($.sensordatavalues[?(@.value_type==‘BME280_temperature’)].value)]" }
Number air1_temp “Outside Temperature [%.1f °C]”

rule “Update Temp"
Item air1_temp_s received update

Not so nice but it’s working :smile: