Skip to content

How to check if json property is null  #1049

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy