SQInteger JSON::parseToken()

in AzureSphereSquirrel/HLCore/json.cpp [146:169]


SQInteger JSON::parseToken(HSQUIRRELVM vm, char *jsonString, jsmntok_t tokens[], unsigned int tokenIndex)
{
    jsmntok_t *token = &tokens[tokenIndex];

    switch(token->type)
    {
        case jsmntype_t::JSMN_OBJECT: return parseObject(vm, jsonString, tokens, tokenIndex);
        case jsmntype_t::JSMN_ARRAY: return parseArray(vm, jsonString, tokens, tokenIndex);
        case jsmntype_t::JSMN_STRING: return parseString(vm, jsonString, tokens, tokenIndex);
        case jsmntype_t::JSMN_PRIMITIVE:
            switch(jsonString[token->start])
            {
                case 't': case 'f': return parseBool(vm, jsonString, tokens, tokenIndex);
                case 'n': return parseNull(vm, jsonString, tokens, tokenIndex);
                case '-': case '0': case '1': case '2':
                case '3': case '4': case '5': case '6':
                case '7': case '8': case '9': return parseNumber(vm, jsonString, tokens, tokenIndex);
                default: return sq_throwerror(vm, "Unknown primitive token");
            }
        break;
        case jsmntype_t::JSMN_UNDEFINED:
        default: return sq_throwerror(vm, "Unknown token type");
    }
}