Пример #1
0
bool JsonIn::skip_value()
{
    char ch;
    bool foundsep;
    eat_whitespace();
    ch = peek();
    // it's either a string '"'
    if (ch == '"') {
        foundsep = skip_string();
    // or an object '{'
    } else if (ch == '{') {
        foundsep = skip_object();
    // or an array '['
    } else if (ch == '[') {
        foundsep = skip_array();
    // or a number (-0123456789)
    } else if (ch == '-' || (ch >= '0' && ch <= '9')) {
        foundsep = skip_number();
    // or "true", "false" or "null"
    } else if (ch == 't') {
        foundsep = skip_true();
    } else if (ch == 'f') {
        foundsep = skip_false();
    } else if (ch == 'n') {
        foundsep = skip_null();
    // or an error.
    } else {
        std::stringstream err;
        err << line_number() << ": expected JSON value but got '" << ch << "'";
        throw err.str();
    }
    return foundsep;//b( foundsep || skip_separator() );
}
Пример #2
0
void JsonIn::skip_value()
{
    char ch;
    eat_whitespace();
    ch = peek();
    // it's either a string '"'
    if (ch == '"') {
        skip_string();
    // or an object '{'
    } else if (ch == '{') {
        skip_object();
    // or an array '['
    } else if (ch == '[') {
        skip_array();
    // or a number (-0123456789)
    } else if (ch == '-' || (ch >= '0' && ch <= '9')) {
        skip_number();
    // or "true", "false" or "null"
    } else if (ch == 't') {
        skip_true();
    } else if (ch == 'f') {
        skip_false();
    } else if (ch == 'n') {
        skip_null();
    // or an error.
    } else {
        std::stringstream err;
        err << "expected JSON value but got '" << ch << "'";
        error(err.str());
    }
    // skip_* end value automatically
}