summaryrefslogtreecommitdiff
path: root/json-glib/json-parser.h
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@openedhand.com>2007-11-10 02:15:44 +0000
committerEmmanuele Bassi <ebassi@openedhand.com>2007-11-10 02:15:44 +0000
commit261d05a4cdcc1f64824615cdc81b4b467d0a5f57 (patch)
tree7c4392c3d1845787bc853b819550e45e0fa3219a /json-glib/json-parser.h
parent4eade1089355ebcf0614d0cfbc9c441513b7d97a (diff)
downloadjson-glib-261d05a4cdcc1f64824615cdc81b4b467d0a5f57.tar.gz
Add support for parsing assignments
Some JSON web APIs return a full JavaScript assignment instead of just the data structure (and I'm looking at you, Tumblr). This is done in clear violation of the grammar published in the RFC 4627, and it's evidently done because most web developers are too lazy for doing a var foo = eval('(' + text ')'); and want everything defined for them. JsonParser will blissfully ignore the left-hand part of the assignment but, in the interest of the developer who cares, will record: 1. that the parsed statement was in fact an assignment and 2. the name of the variable used. The function json_parser_has_assignment() can be used to query both the presence of an assignment and the variable name at the same time.
Diffstat (limited to 'json-glib/json-parser.h')
-rw-r--r--json-glib/json-parser.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/json-glib/json-parser.h b/json-glib/json-parser.h
index 71a17cb..37324a9 100644
--- a/json-glib/json-parser.h
+++ b/json-glib/json-parser.h
@@ -53,9 +53,12 @@ typedef enum {
typedef enum {
JSON_TOKEN_INVALID = G_TOKEN_LAST,
+
JSON_TOKEN_TRUE,
JSON_TOKEN_FALSE,
JSON_TOKEN_NULL,
+ JSON_TOKEN_VAR,
+
JSON_TOKEN_LAST
} JsonTokenType;
@@ -141,6 +144,8 @@ JsonNode * json_parser_get_root (JsonParser *parser);
guint json_parser_get_current_line (JsonParser *parser);
guint json_parser_get_current_pos (JsonParser *parser);
+gboolean json_parser_has_assignment (JsonParser *parser,
+ gchar **variable_name);
G_END_DECLS