1 /* ---------------------------------------------------------------------------------------
3 * --------------------------------------------------------------------------------------- */
16 /* returns NULL on error. if string is NULL, returns an object whose is_null flag
18 object* json_parse_string(char* string);
20 /* does the actual parsing work. returns 0 on success. -1 on error and
21 * -2 if there was no object to build (string was all comments)
23 int _json_parse_string(char* string, unsigned long* index, object* obj);
25 /* returns 0 on success and turns obj into a string object */
26 int json_parse_json_string(char* string, unsigned long* index, object* obj);
28 /* returns 0 on success and turns obj into a number or double object */
29 int json_parse_json_number(char* string, unsigned long* index, object* obj);
31 int json_parse_json_object(char* string, unsigned long* index, object* obj);
33 /* returns 0 on success and turns object into an array object */
34 int json_parse_json_array(char* string, unsigned long* index, object* obj);
36 /* churns through whitespace and increments index as it goes.
37 * eat_all means we should eat newlines, tabs
39 void json_eat_ws(char* string, unsigned long* index, int eat_all);
41 int json_parse_json_bool(char* string, unsigned long* index, object* obj);
43 /* removes comments from a json string. if the comment contains a class hint
44 * and class_hint isn't NULL, an allocated char* with the class name will be
45 * shoved into *class_hint. returns 0 on success, -1 on parse error.
46 * 'index' is assumed to be at the second character (*) of the comment
48 int json_eat_comment(char* string, unsigned long* index, char** class_hint, int parse_class);
50 /* prints a useful error message to stderr. always returns -1 */
51 int json_handle_error(char* string, unsigned long* index, char* err_msg);
53 /* returns true if c is 0-9 */
54 int is_number(char c);
56 int json_parse_json_null(char* string, unsigned long* index, object* obj);