json: Update JsonParser

Add another fix from upstream, to clean up the code.
This commit is contained in:
Emmanuele Bassi 2010-03-19 11:13:04 +00:00
parent 295bc517f8
commit 66e0f18753

View File

@ -512,22 +512,20 @@ 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,22 +752,20 @@ 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);