summaryrefslogtreecommitdiff
path: root/json.h
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-28 10:24:13 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-28 10:24:13 +0000
commit4769babfa5a2cad6666eb5d44e8ad109a5528d25 (patch)
tree9f6665a61592f84f5b8f68603ded5486f6833720 /json.h
parent511cfba4940624602c4ea5fbb622c7989d8acc2e (diff)
downloadgpsd-4769babfa5a2cad6666eb5d44e8ad109a5528d25.tar.gz
Allow mapping of strings to enumerated values in JSON.
Diffstat (limited to 'json.h')
-rw-r--r--json.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/json.h b/json.h
index 30ca4c1a..bcf7ab8b 100644
--- a/json.h
+++ b/json.h
@@ -9,6 +9,11 @@ typedef enum {integer, uinteger, real, string, boolean, character,
#define nullbool -1 /* not true, not false */
+struct json_enum_t {
+ char *name;
+ int value;
+};
+
struct json_array_t {
json_type element_type;
union {
@@ -48,6 +53,7 @@ struct json_attr_t {
char *check;
} dflt;
size_t len;
+ const struct json_enum_t *map;
};
#define JSON_ATTR_MAX 31 /* max chars in JSON attribute name */
@@ -74,8 +80,8 @@ const char *json_error_string(int);
#define JSON_ERR_BADSTRING 15 /* error while string parsing */
#define JSON_ERR_CHECKFAIL 16 /* check attribute not matched */
#define JSON_ERR_NOPARSTR 17 /* can't support strings in parallel arrays */
-#define JSON_ERR_MISC 18 /* other data conversion error */
-
+#define JSON_ERR_BADENUM 18 /* invalid enumerated value */
+#define JSON_ERR_MISC 19 /* other data conversion error */
/*
* Use the following macros to declare template initializers for structobject