Replies: 3 comments
-
The documentation (https://json.nlohmann.me/api/basic_json/value) states:
Your change would break this contract, so we unfortunately cannot make it. |
Beta Was this translation helpful? Give feedback.
-
If the requested value is |
Beta Was this translation helpful? Give feedback.
-
In my mind the default value would be returned in the event of a failure. But I can see the importance in the distinction between not found and invalid request, especially in the context of lists and literal types. Thank you for the prompt feedback. |
Beta Was this translation helpful? Give feedback.
-
Using the value function on an empty json throws an exception. I propose simply returning the default value because ultimately (for me at least) that seems like it would be the appropriate behavior for not finding the value requested.
For anyone wondering how to currently work around the thrown exception, assign a nlohmann::json::initializer_list_t to the json object before calling value.
Beta Was this translation helpful? Give feedback.
All reactions