Skip to content

How to check if json property is null  #1049

Closed
@vaz83

Description

@vaz83

Hello,
what's the best way to check if a json property exists or has value ? i was trying to make the condition jDoc["relayInterval"]!=NULL but it's not working.
`
File configFile = SPIFFS.open("/configsa.json", "r");
size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
DynamicJsonDocument jDoc(2500);
DeserializationError error = deserializeJson(jDoc,buf.get());
if (!error)
{
if(jDoc["relayInterval"]!=NULL)
strcpy(relay_interval,jDoc["relayInterval"]);
}
'

Metadata

Metadata

Assignees

No one assigned

    Labels

    v6ArduinoJson 6

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions