forked from Telodendria/Telodendria
Fix bugs in Json API.
This commit is contained in:
parent
31be432f7a
commit
7703405c70
2 changed files with 27 additions and 14 deletions
8
TODO.txt
8
TODO.txt
|
@ -13,9 +13,11 @@ Milestone: v0.2.0
|
||||||
|
|
||||||
[ ] Abstract /email/requestToken and /msidsn/requestToken
|
[ ] Abstract /email/requestToken and /msidsn/requestToken
|
||||||
|
|
||||||
[ ] Json API
|
[x] Json API
|
||||||
[ ] Trailing commas should not be allowed in arrays and objects
|
[x] Trailing commas should not be allowed in arrays and objects
|
||||||
[ ] Fix empty arrays not parsing
|
[x] Fix empty arrays not parsing
|
||||||
|
[ ] Db API
|
||||||
|
[ ] If object is in cache, but doesn't exist on disk, delete from cache
|
||||||
[~] User login
|
[~] User login
|
||||||
[x] User manipulation functions (so we don't use the DB directly)
|
[x] User manipulation functions (so we don't use the DB directly)
|
||||||
[x] Refresh tokens
|
[x] Refresh tokens
|
||||||
|
|
33
src/Json.c
33
src/Json.c
|
@ -945,6 +945,7 @@ static HashMap *
|
||||||
JsonDecodeObject(JsonParserState * state)
|
JsonDecodeObject(JsonParserState * state)
|
||||||
{
|
{
|
||||||
HashMap *obj = HashMapCreate();
|
HashMap *obj = HashMapCreate();
|
||||||
|
int comma = 0;
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
|
@ -986,19 +987,21 @@ JsonDecodeObject(JsonParserState * state)
|
||||||
Free(key);
|
Free(key);
|
||||||
|
|
||||||
JsonTokenSeek(state);
|
JsonTokenSeek(state);
|
||||||
|
|
||||||
|
if (JsonExpect(state, TOKEN_COMMA))
|
||||||
|
{
|
||||||
|
comma = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (JsonExpect(state, TOKEN_OBJECT_CLOSE))
|
if (JsonExpect(state, TOKEN_OBJECT_CLOSE))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JsonExpect(state, TOKEN_COMMA))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
else if (JsonExpect(state, TOKEN_OBJECT_CLOSE))
|
else if (!comma && JsonExpect(state, TOKEN_OBJECT_CLOSE))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1019,6 +1022,7 @@ JsonDecodeArray(JsonParserState * state)
|
||||||
{
|
{
|
||||||
Array *arr = ArrayCreate();
|
Array *arr = ArrayCreate();
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int comma = 0;
|
||||||
|
|
||||||
if (!arr)
|
if (!arr)
|
||||||
{
|
{
|
||||||
|
@ -1030,6 +1034,12 @@ JsonDecodeArray(JsonParserState * state)
|
||||||
JsonValue *value;
|
JsonValue *value;
|
||||||
|
|
||||||
JsonTokenSeek(state);
|
JsonTokenSeek(state);
|
||||||
|
|
||||||
|
if (!comma && JsonExpect(state, TOKEN_ARRAY_CLOSE))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
value = JsonDecodeValue(state);
|
value = JsonDecodeValue(state);
|
||||||
|
|
||||||
if (!value)
|
if (!value)
|
||||||
|
@ -1041,16 +1051,17 @@ JsonDecodeArray(JsonParserState * state)
|
||||||
|
|
||||||
JsonTokenSeek(state);
|
JsonTokenSeek(state);
|
||||||
|
|
||||||
|
if (JsonExpect(state, TOKEN_COMMA))
|
||||||
|
{
|
||||||
|
comma = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (JsonExpect(state, TOKEN_ARRAY_CLOSE))
|
if (JsonExpect(state, TOKEN_ARRAY_CLOSE))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JsonExpect(state, TOKEN_COMMA))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto error;
|
goto error;
|
||||||
} while (!JsonExpect(state, TOKEN_EOF));
|
} while (!JsonExpect(state, TOKEN_EOF));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue