json_object_get_string_member() not as that convenient
The json_object_get_string_member()
is documented as:
Convenience function that retrieves the string value stored in member_name of object
See also: json_object_get_member()
While the json_object_get_member()
can return NULL
, the json_object_get_string_member()
cannot, it rather prints a runtime warning:
Json-CRITICAL **: 15:42:02.580: json_object_get_string_member: assertion 'node != NULL' failed
which is really not convenient in cases where I know the value can be there, but I do not know whether it is there. This can apply to other json_object_get_XXXX_member()
functions as well.
I can either use json_object_get_member()
(and basically implement the convenient function myself) or prepend json_object_has_member()
to every json_object_get_XXXX_member()
call, but you can see it's not as that convenient as it could be.
Maybe the problem is with non-object/string values, where is not known preferred default value (like for int
once it might be 0 when the member does not exists and another time a value of -1
or such).