Best way to handle json files with missing key value pairs. #1893
Labels
kind: question
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
There are two possible ways (maybe more that I missed) to check if key is present in the json.
Json J;
j.contains("mykey") == true?
auto it = j.find("mykey");
I have a test application where the configuraton properties (json key/val) may or may not be present as it is based on the test case. I don't want to do j.find or j.contains for every key before parsing it into the class. Is there a better way to ignore or return default value when a json key/val is not present in the json file?
Currently j.at("mykey").get_to(value) throws error if the mykey is not present in json.
The text was updated successfully, but these errors were encountered: