You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
intmain()
{
json_value_t*val=json_value_parse("...");
// The following castings are legal if 'val' is the corresponding type.constchar*str=*(constchar**)val; // equal to: str = json_value_string(val);doublenum=*(double*)val; // equal to: num = json_value_number(val);json_object_t*obj= (json_object_t*)val; // equal to: obj = json_value_object(val);json_array_t*arr= (json_array_t*)val; // equal to: arr = json_value_array(val);
}
Because the JSON value shares the same address with it's data, and this was designed on purpose and you may always make use of this feature. In json_parser.c, the JSON value structure is defined as:
The JSON value's data are always the first fields, so the addresses of them are identical to the value. You can cast reversely as well by casting an object or an array to a JSON value.
The text was updated successfully, but these errors were encountered:
A JSON value can be cast directly to it's data:
Because the JSON value shares the same address with it's data, and this was designed on purpose and you may always make use of this feature. In json_parser.c, the JSON value structure is defined as:
The JSON value's data are always the first fields, so the addresses of them are identical to the value. You can cast reversely as well by casting an object or an array to a JSON value.
The text was updated successfully, but these errors were encountered: