Parameters file defines the creation of entities and stored in flash. Its structure is given, and all fields ( keys & values ) are given. In current phase - those parameters are hard-coded in a const char* cont_params, as shown below.

My goal, is when array is empty, for example RF_2entity - means that current MCU does not uses its RF abilities, and will not init any RF entities. The way RF_2entity is defined below, as empty array, [] , ArduinoJSON's isNull() function return 0 in that case.

How can I keep parameters file's structure and logic, rather that fill its values with 255 for example.

  StaticJsonDocument<1200> doc;
  const char *cont_params = "{\"entityType\": [1,1,1,1],\
                    \"SWname\": [\"SW_0\",\"SW_1\",\"SW_2\",\"SW_3\"],\
                    \"SW_buttonTypes\": [2,1,1,1],\
                    \"SW_timeout\": [10,11,12,13],\
                    \"Winname\": [],\
                    \"WextInputs\": [],\
                    \"RF_2entity\": [],\
                    \"v_file\": 0.5}";
  DeserializationError err = deserializeJson(doc, cont_params);
  JsonArray array = doc["Winname"].as<JsonArray>();


  • sorry, but I don't understand the question. what is the problem? isNull() returned 0 (false), not 1 (true)
    – Juraj
    Jun 2, 2023 at 5:08
  • @Juraj - Question edited. you are right.... isNull() returns that array is not empty.
    – guyd
    Jun 2, 2023 at 5:18

1 Answer 1


The method isNull() is not what you want. It tells you whether the instance holds an array at all or not. And of course, your specific instance holds an array, though an empty one. Therefore, the method correctly returns false, aka 0.

As the API documentation shows, there are more methods to use.

What you want is size(), which returns the number of elements in the array. It will even return 0 on an instance without an array.

  • in that case, doc["Winname"].size() will suffice. I don't really need to use an array.
    – guyd
    Jun 2, 2023 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.