This page last changed on Feb 12, 2016 by moltes.

Hello,

I created a sensor with a command:
Protocol : HTTP
Url : http://MYIP:8080/json.htm?type=devices&rid=41
Http Method : GET
Polling interval : 60s
jsonpath expression : $.result\*.Data

IN IE Response:

{ "ActTime" : 1455304067, "ServerTime" : "2016-02-12 20:07:47", "Sunrise" : "07:57", "Sunset" : "17:48", "result" : [ { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "Barometer" : 994, "BatteryLevel" : 255, "CustomImage" : 0, "Data" : "0.4 C, 82 %, 994 hPa", "Description" : "", "DewPoint" : "-2.31", "Favorite" : 0, "Forecast" : 4, "ForecastStr" : "Rain", "HardwareID" : 6, "HardwareName" : "Météo", "HardwareType" : "Weather Underground", "HardwareTypeVal" : 14, "HaveTimeout" : false, "Humidity" : 82, "HumidityStatus" : "Wet", "ID" : "0001", "LastUpdate" : "2016-02-12 20:01:14", "Name" : "Marchin", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : "-", "SubType" : "THB1 - BTHR918, BTHGN129", "Temp" : 0.40, "Timers" : "false", "Type" : "Temp + Humidity + Baro", "TypeImg" : "temperature", "Unit" : 1, "Used" : 1, "XOffset" : "0", "YOffset" : "0", "forecast_url" : "", "idx" : "41" } ], "status" : "OK", "title" : "Devices" } 

on my "Data" I have 3 data but I will recover only the first ... What I have to add to my jsonpath expression code ? but I do not want use $.result\*.Temp because I will miss so the C or The %

somebody for help me?

Thxxxxx

Dany

This is not correct json. Please surround the json in your post with {code}...{code} tags, so I can see it and help.

Posted by pz1 at Feb 12, 2016 17:16

hi

thank you

my code is good now?

Posted by moltes at Feb 12, 2016 19:11

Well lets first layout the json a bit nicer (with Notepad++ JSFormat):

{
	"ActTime" : 1455304067,
	"ServerTime" : "2016-02-12 20:07:47",
	"Sunrise" : "07:57",
	"Sunset" : "17:48",
	"result" : [{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"Barometer" : 994,
			"BatteryLevel" : 255,
			"CustomImage" : 0,
			"Data" : "0.4 C, 82 %, 994 hPa",
			"Description" : "",
			"DewPoint" : "-2.31",
			"Favorite" : 0,
			"Forecast" : 4,
			"ForecastStr" : "Rain",
			"HardwareID" : 6,
			"HardwareName" : "Météo",
			"HardwareType" : "Weather Underground",
			"HardwareTypeVal" : 14,
			"HaveTimeout" : false,
			"Humidity" : 82,
			"HumidityStatus" : "Wet",
			"ID" : "0001",
			"LastUpdate" : "2016-02-12 20:01:14",
			"Name" : "Marchin",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : [0],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "THB1 - BTHR918, BTHGN129",
			"Temp" : 0.40,
			"Timers" : "false",
			"Type" : "Temp + Humidity + Baro",
			"TypeImg" : "temperature",
			"Unit" : 1,
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"forecast_url" : "",
			"idx" : "41"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}

With JsonPath I can only retreive the full field value (0.4) like you have done for "Temp",
or with jsonpath:

$.result..Data

I can extract the complete Data field (mind the two dots between result and Data)

http://jsonpath.com/ is a good online tool to experiment with jsonpath experessions

Posted by pz1 at Feb 12, 2016 22:18
Document generated by Confluence on Jun 05, 2016 09:33