String severity = myObject["features"]["severity"];
If you run a curl cli command on your PC to the url https://api.weather.gov/alerts/active?zone=OHC093, it returns a json object as shown below (with part of the elements removed to only highlight the structure):
{
// ...
"features": [
{
// ...
"properties": {
// ...
"severity": "Severe",
// ...
"event": "Flood Warning"
// ...
},
},
],
// ...
}
Noticed that the features is an array element, so to access it, it is myObject["features"][0]. So theThe "severity" element is an element of "properties". The correct code isshould therefore be:
JsonDocument doc;
DeserializationError error = deserializeJson(doc, input);
JsonObject myObject = doc["features"][0];
JsonObject propertyObj = myObject["properties"];
const char* severity = propertyObj["severity"];
const char* event = propertyObj["event"];
BTW, ArduinoJson library offers online tool ArduinoJson Assistant for helping you to serialise and deserialise an JSON object.