Convert a numeric JSON value to a long.
MCO_RET mcorest_api_json_numeric_as_long( const char *str, long *val );
str
val
long.This function converts a numeric JSON value to a
long. Ifstrdoes not contain an integer, it returns an error code.
char buf[32];
mcorest_api_json_read_ctx_t jctx;
MCOREST_API_JSON_TKN_TYPE tkn_type;
...
if (MCO_S_OK == mcorest_api_json_next_token(&jctx, MCOREST_API_JSON_TKN_NUMBER, &tkn_type))
{
if (MCO_S_OK == mcorest_api_json_read_numeric(&jctx, buf, sizeof(buf)))
{
if (mcorest_api_json_numeric_is_integer(buf))
{
long val;
mcorest_api_json_numeric_as_long(buf, &val); /* convert numeric value to signed long integer */
}
}
}