Add macro to check for required json keys#112
Add macro to check for required json keys#112DevwratJoshi wants to merge 5 commits intomujin:masterfrom
Conversation
Should not return false if the value is null, as long as the key exists
|
oh @DevwratJoshi actually you might need to port controllercommon!488 as well. |
|
ask Yoshiki if required |
| #include <rapidjson/prettywriter.h> | ||
|
|
||
| #ifndef MUJINCLIENTJSON_LOAD_REQUIRED_JSON_VALUE_BY_KEY | ||
| #define MUJINCLIENTJSON_LOAD_REQUIRED_JSON_VALUE_BY_KEY(rValue, key, param) \ |
There was a problem hiding this comment.
Is there a reason this is a macro instead of a function LoadRequiredJsonValueByKey?
There was a problem hiding this comment.
ya, actually I also think function is better, then we can put it in a namespace...
There was a problem hiding this comment.
should we talk in controllercommon!489 ?
There was a problem hiding this comment.
I see, Ziyan brought up the same concern here. Let's keep discussion here for now.
There was a problem hiding this comment.
That makes you, me and @ziyan arguing for a function over a macro then
|
@cielavenir Yoshiki said that the changes from controllercommon!488 could be better, so they might be changed in the future. By the way, the behaviour in master for |
My understanding is that Webstack will not distinguish between fields that are unset and fields that are set to cc @ziyan |
|
Does anyone have any issues with this change? I don't. |
LoadJsonValueByKeynow returns a bool. If the key does not exist in the document the function will return false, else will return true.MUJINCLIENTJSON_LOAD_REQUIRED_JSON_VALUE_BY_KEY) is added, wrappingLoadJsonValueByKey. If the keys are not in the document, an exception is thrown.