I have been using Open Weather and Weather Undground APIs for some time. I recently learned the National Weather Service has an API for alerts. I can print out the raw data but not able to parse it. The JSON format seems a little different then what I am use to.
This is the link to the information I want to parse: https://api.weather.gov/alerts/active?zone=OHC093
Using Arduino_JSON.h I have been doing the following test code to see if I can get the information I would like.
void ParseWeatherAlerts() {
Serial.println("\t**** Parse Weather Alerts *****");
JSONVar myObject = JSON.parse(NWS_Current_Severe_Weather_Alerts);
// JSON.typeof(jsonVar) can be used to get the type of the var
if (JSON.typeof(myObject) == "undefined") {
if (flgDebug) {
Serial.println("\n\tParsing input failed!");
}
return;
}
String severity = myObject["features"]["severity"];
String event = myObject["features"]["event"];
Serial.print("\tSeverity = ");
Serial.println(severity);
Serial.print("\tAlert Event = ");
Serial.println(event);
}
I get no information printed out. Been working on this for hours. The API seems to put out some odd data and I can't determine the KEYS for jSON
I get no information printed out... that makes no sense ... you have several lines that print fixed text ... those should be printing["features"]["severity"]in the JSON file?