Probably something easy but I’ve not resolved it.
I’m extracting data from a JSON string and all the values are correct accept for two.
They are referring to two date time values and are in milliseconds.
One is the date refreshed and the other is date updated.
Problem is they are both very large and I’m having difficulty assigning them in the IDE.
One is 1588447162117 which is showing as 020-05-02 20:19:53.948 on the dashboard using the JSON.
Here is the code I have thus far to get the data from JSON:
#include <ArduinoJson.h>
void setup() {
Serial.begin(4800);
const char* input = "{TotalCases:3308678,TotalCasesToday:4458,TotalDeaths:234123,TotalDeathsToday:293,TotalRecovered:1042991,TotalTerritories:124,CurrentUpdatedMS:1588312648603,CurrentChangedMS:1588312648603}";
StaticJsonDocument<512> doc;
DeserializationError err = deserializeJson(doc, input);
if (err) {
Serial.print("Error: ");
Serial.println(err.c_str());
return;
}
unsigned long TotalCases = doc["TotalCases"];
unsigned long TotalCasesToday = doc["TotalCasesToday"];
unsigned long TotalDeaths = doc["TotalDeaths"];
unsigned long TotalDeathsToday = doc["TotalDeathsToday"];
unsigned long TotalRecovered = doc["TotalRecovered"];
unsigned long TotalTerritories = doc["TotalTerritories"];
unsigned long CurrentUpdatedMS = doc["CurrentUpdatedMS"];
unsigned long CurrentChangedMS = doc["CurrentChangedMS"];
Serial.print("Total Cases: ");
Serial.println(TotalCases);
Serial.print("Total Cases Today: ");
Serial.println(TotalCasesToday);
Serial.print("Total Deaths: ");
Serial.println(TotalDeaths);
Serial.print("Total Deaths Today: ");
Serial.println(TotalDeathsToday);
Serial.print("Total Recovered: ");
Serial.println(TotalRecovered);
Serial.print("Total Territories: ");
Serial.println(TotalTerritories);
Serial.print("Update time in ms:");
Serial.println(CurrentUpdatedMS);
Serial.print("Change time in ms:");
Serial.print(CurrentChangedMS);
}
void loop()
{
}
**Serial monitor output**
Total Cases: 3308678
Total Cases Today: 4458
Total Deaths: 234123
Total Deaths Today: 293
Total Recovered: 1042991
Total Territories: 124
Update time in ms:0
Change time in ms:0
Should be good to manipulate it once I can work with it in a variable.
Thanks for any input,
Shane