mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
json: Update JsonParser
Add another fix from upstream, to clean up the code.
This commit is contained in:
parent
295bc517f8
commit
66e0f18753
@ -512,21 +512,19 @@ json_parse_array (JsonParser *parser,
|
|||||||
}
|
}
|
||||||
|
|
||||||
token = g_scanner_get_next_token (scanner);
|
token = g_scanner_get_next_token (scanner);
|
||||||
if (token == G_TOKEN_RIGHT_BRACE)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (token == G_TOKEN_COMMA)
|
if (token == G_TOKEN_COMMA)
|
||||||
{
|
{
|
||||||
token = g_scanner_get_next_token (scanner);
|
token = g_scanner_get_next_token (scanner);
|
||||||
if (token == G_TOKEN_RIGHT_BRACE)
|
if (token == G_TOKEN_RIGHT_BRACE)
|
||||||
return G_TOKEN_SYMBOL;
|
return G_TOKEN_SYMBOL;
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else if (token != G_TOKEN_RIGHT_BRACE)
|
||||||
|
{
|
||||||
|
json_array_unref (array);
|
||||||
|
|
||||||
json_array_unref (array);
|
return G_TOKEN_RIGHT_BRACE;
|
||||||
|
}
|
||||||
return G_TOKEN_RIGHT_BRACE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json_node_take_array (priv->current_node, array);
|
json_node_take_array (priv->current_node, array);
|
||||||
@ -590,6 +588,7 @@ json_parse_object (JsonParser *parser,
|
|||||||
return G_TOKEN_STRING;
|
return G_TOKEN_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* nested object */
|
||||||
if (token == G_TOKEN_LEFT_CURLY)
|
if (token == G_TOKEN_LEFT_CURLY)
|
||||||
{
|
{
|
||||||
JsonNode *old_node = priv->current_node;
|
JsonNode *old_node = priv->current_node;
|
||||||
@ -640,6 +639,7 @@ json_parse_object (JsonParser *parser,
|
|||||||
return G_TOKEN_RIGHT_CURLY;
|
return G_TOKEN_RIGHT_CURLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* nested array */
|
||||||
if (token == G_TOKEN_LEFT_BRACE)
|
if (token == G_TOKEN_LEFT_BRACE)
|
||||||
{
|
{
|
||||||
JsonNode *old_node = priv->current_node;
|
JsonNode *old_node = priv->current_node;
|
||||||
@ -752,21 +752,19 @@ json_parse_object (JsonParser *parser,
|
|||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
token = g_scanner_get_next_token (scanner);
|
token = g_scanner_get_next_token (scanner);
|
||||||
if (token == G_TOKEN_RIGHT_CURLY)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (token == G_TOKEN_COMMA)
|
if (token == G_TOKEN_COMMA)
|
||||||
{
|
{
|
||||||
token = g_scanner_get_next_token (scanner);
|
token = g_scanner_get_next_token (scanner);
|
||||||
if (token == G_TOKEN_RIGHT_CURLY)
|
if (token == G_TOKEN_RIGHT_CURLY)
|
||||||
return G_TOKEN_SYMBOL;
|
return G_TOKEN_SYMBOL;
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else if (token != G_TOKEN_RIGHT_CURLY)
|
||||||
|
{
|
||||||
|
json_object_unref (object);
|
||||||
|
|
||||||
json_object_unref (object);
|
return G_TOKEN_RIGHT_CURLY;
|
||||||
|
}
|
||||||
return G_TOKEN_RIGHT_CURLY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json_node_take_object (priv->current_node, object);
|
json_node_take_object (priv->current_node, object);
|
||||||
|
Loading…
Reference in New Issue
Block a user