mcorest_api_json_read_numeric

Read a numeric value as a string from the input stream.

For an overview see page mcorest_api_json_read_*

Prototype

    MCO_RET mcorest_api_json_read_numeric(mcorest_api_json_read_ctx_t *ctx,
                            char *buf,
                            int len);

Arguments

ctx
Pointer to the JSON read context structure.
buf
The buffer to read data into (this buffer is never zero-terminated).
len
On input, defines the size of the buffer. On output, returns the actual number of characters written into the buffer.

Description

This function reads a numeric value as a string and does basic sanity checks. The buffer is never zero-terminated; the value is truncated if it does not fit.

Return Codes

MCO_S_OK = 0
Success.
MCO_E_REST_*
Any of the Web Services Error Codes.

Example

    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)))
        {
            /* buf now contains a numeric string from the JSON input */
        }
    }

Files

Header file:
mcorestapi.h
Source file:
jsonrd.c
Library:
libmcorest.a