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.
Serial.begin(115200);
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],\
\"SWvirtCMD\":[0,0,0,0],\
\"Winname\": [],\
\"WextInputs\": [],\
\"WinvirtCMD\":[],\
\"RF_2entity\": [],\
\"v_file\": 0.5}";
DeserializationError err = deserializeJson(doc, cont_params);
JsonArray array = doc["Winname"].as<JsonArray>();
serializeJsonPretty(array,Serial);
Serial.println(array.isNull());
output:
[]0
isNull()
returns that array is not empty.