Open xback opened 3 months ago
When an optional string is not found, all optional strings behind it are skipped
JSON provided in json_t* A:
{ "azimuth": null, "latitude": "51.36028611", "longitude": "4.27114444", "height": null, "Managable": null, "SIM_ICCID": null, "SIM_MTN": null, "TruckLicensePlate": null, "TruckSerialNumber": null, "monitoring_environment": "Industry", "monitoring_job_override": null, "node_id": null, "sla": "Gold" }
C reproducer:
void test(json_t* A) { const char* str_azi = NULL; const char* str_lat = NULL; const char* str_lon = NULL; const char* str_alt = NULL; //Optionally extract values which are present // All fail (pointers remain empty) json_unpack(A, "{s?s, s?s, s?s, s?s}", \ "azimuth", &str_azi, \ "latitude", &str_lat, \ "longitude", &str_lon, \ "height", &str_alt); // Works (latitude and longitude are both extracted as expected) json_unpack(A, "{s?s, s?s, s?s, s?s}", \ "latitude", &str_lat, \ "longitude", &str_lon, \ "azimuth", &str_azi, \ "height", &str_alt); }
When an optional string is not found, all optional strings behind it are skipped
JSON provided in json_t* A:
C reproducer: