diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-08-19 02:25:32 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-08-19 02:25:32 +0000 |
commit | 747088bbe5dc34c0902c0bddc492bc4815f4a7c3 (patch) | |
tree | 4c2d4ef502290f6e7ce9136a30b6284f6d7e1bcc /json.h | |
parent | 276ffa0a53aae3fe555bdcbf98c4007120a2f0e3 (diff) | |
download | gpsd-747088bbe5dc34c0902c0bddc492bc4815f4a7c3.tar.gz |
Give the JSON parser the ability to map strings to enumerated types.
Diffstat (limited to 'json.h')
-rw-r--r-- | json.h | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -4,10 +4,16 @@ #include <stdbool.h> #include <ctype.h> -typedef enum {integer, real, string, boolean, object, array, check} json_type; +typedef enum {integer, real, string, boolean, + enumerated, object, array, check} json_type; #define nullbool -1 /* not true, not false */ +struct json_enum_t { + char *name; + int value; +}; + struct json_array_t { json_type element_type; union { @@ -17,6 +23,11 @@ struct json_array_t { char *store; int storelen; } strings; + struct { + const struct json_enum_t *map; + int *store; + int storelen; + } enumerated; } arr; int *count, maxlen; }; @@ -66,5 +77,6 @@ const char *json_error_string(int); #define JSON_ERR_SUBTYPE 14 /* unsupported array element type */ #define JSON_ERR_BADSTRING 15 /* error while string parsing */ #define JSON_ERR_CHECKFAIL 16 /* check attribute not matched */ +#define JSON_ERR_BADENUM 17 /* invalid enumerated value */ /* json.h ends here */ |