# mcorest_api_json_numeric_as_i64

Convert a numeric JSON value to a `mco_int8` value.

### For an overview see page mcorest_api_json_read_*

### Prototype

        MCO_RET mcorest_api_json_numeric_as_i64( const char *str, mco_int8 *val );

### Arguments

str | A numeric JSON value
val | The address of a 64 bit integer

### Description

> This function converts a numeric JSON value to a 64 bit integer. If `str` does not contain an integer, it returns an error code.

### 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)))
            {
                if (mcorest_api_json_numeric_is_integer(buf))
                {
                    mco_int8 val;
                    mcorest_api_json_numeric_as_i64(buf, &val); /* convert numeric value to signed 64-bit integer */
                }
            }
        }

### Files

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