static apr_status_t apr_json_decode_value()

in json/apr_json_decode.c [719:778]


static apr_status_t apr_json_decode_value(apr_json_scanner_t * self, apr_json_value_t ** retval)
{
    apr_json_value_t value;
    apr_status_t status = APR_SUCCESS;

    status = apr_json_decode_space(self, &value.pre);

    if (status == APR_SUCCESS) {
        switch (*(unsigned char *) self->p) {
        case '"':
            value.type = APR_JSON_STRING;
            status = apr_json_decode_string(self, &value.value.string);
            break;
        case '[':
            value.type = APR_JSON_ARRAY;
            status = apr_json_decode_array(self, &value);
            break;
        case '{':
            value.type = APR_JSON_OBJECT;
            status = apr_json_decode_object(self, &value, &value.value.object);
            break;
        case 'n':
            value.type = APR_JSON_NULL;
            status = apr_json_decode_null(self);
            break;
        case 't':
        case 'f':
            value.type = APR_JSON_BOOLEAN;
            status = apr_json_decode_boolean(self, &value.value.boolean);
            break;
        case '-':
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            status = apr_json_decode_number(self, &value);
            break;
        default:
            status = APR_BADCH;
        }
    }

    if (status == APR_SUCCESS) {
        status = apr_json_decode_space(self, &value.post);
    }

    if (status == APR_SUCCESS) {
        *retval = apr_pmemdup(self->pool, &value, sizeof(value));
    }
    else {
        *retval = NULL;
    }
    return status;
}