Ich erhalte JSON-Daten mithilfe von HTTP-Methoden in Arduino und Speichern in einem String-Objekt. Die Daten sind:Parse JSON-Daten aus Zeichenfolge
{
"item": {
"Identity": {
"Id": "327681",
"ItemId": "64006A962B71A1E7B3A0428637DA997C.327681",
"Level": 1,
"EntityType": "64006A962B71A1E7B3A0428637DA997C",
"ItemStatus": 1
},
"Properties": {
"AssetName": "PHE-1001",
"Category": "Electrical Appliance",
"RegistrationTime": "2017-12-14Z",
"Activated": true,
"Status": "Offline",
"Manufacturer": "Philips",
"ModelNumber": "1E-S00ER11",
"SerialNumber": "YGTJGJK458545",
"sample_property": null,
"AssetLocation": null,
"AssetType": null,
"ActivationTime": "2017-12-24T05:44:38Z",
"Country": "India",
"PostalAddress": "500081",
"dummy": null,
"TotalHours": 16,
"TotalWorkingHoursFromInstallation": 38,
"TotalLifeTime": 62,
"AssetSensorDistance": null
}
}
}
Arduino Code:
HTTPClient http;
http.begin("URL");
int httpCode = http.GET(); // //Send the request
if (httpCode == 200) {
String payload = http.getString();
Serial.println(payload);
}
Jetzt möchte ich nur AssetName
, Status
und AssetSensorDistance
bekommen. Ich habe versucht payload["Status"]
, aber es druckt nichts.
Kann mir jemand dabei helfen? Danke im Voraus.
StaticJsonBuffer <200> jsonBuffer; JsonObject & root = jsonBuffer.parseObject (Nutzlast); if (! Root.success()) { Serial.println ("Parsing fehlgeschlagen"); } es ist Drucken "Parsing fehlgeschlagen" –
Ihr Eingabepuffer ist zu klein, Sie benötigen mindestens 842 Bytes. Sieh dies, http://arduinojson.org/faq/why-parsing-fails/ und auch dieses wirklich coole Tool: http://arduinojson.org/assistant/. Btw hat das durch googeln "ArduinoJson parsing failed" ... Google ist dein Freund :-) – Yaro