aboutsummaryrefslogtreecommitdiff
path: root/src/json.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.h')
-rw-r--r--src/json.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/json.h b/src/json.h
new file mode 100644
index 0000000..e089692
--- /dev/null
+++ b/src/json.h
@@ -0,0 +1,68 @@
+/* This file is part of Grecs.
+ Copyright (C) 2012-2015 Sergey Poznyakoff.
+
+ Grecs is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Grecs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Grecs. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <grecs.h>
+
+enum json_value_type
+{
+ json_null,
+ json_bool,
+ json_number,
+ json_string,
+ json_arr,
+ json_object
+};
+
+struct json_value;
+struct json_array {
+ size_t oc;
+ struct json_value **ov;
+};
+
+struct json_value {
+ enum json_value_type type;
+ union {
+ int b; /* json_bool */
+ double n; /* json_number */
+ char *s; /* json_string */
+ struct json_array *a; /* json_arr */
+ struct grecs_symtab *o; /* json_object */
+ } v;
+};
+
+struct json_pair {
+ char *k;
+ struct json_value *v;
+};
+
+extern char const *json_err_diag;
+extern struct grecs_locus json_err_locus;
+extern struct json_value *json_return_obj;
+
+void jsonlex_setup(char const *s, size_t l);
+void jsonlex_diag(const char *s);
+int json_unescape(int c, int *o);
+
+struct json_value *json_value_create(int type);
+struct grecs_symtab *json_assoc_create(void);
+void json_value_free(struct json_value *obj);
+
+struct json_value *json_parse_string(char const *input, size_t len);
+
+struct json_value *json_value_lookup(struct json_value *obj,
+ const char *ident);
+
+

Return to:

Send suggestions and report system problems to the System administrator.