summaryrefslogtreecommitdiff
path: root/src/shared/json.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/json.h')
-rw-r--r--src/shared/json.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/shared/json.h b/src/shared/json.h
index 2ce56420a3..e0b4d810b5 100644
--- a/src/shared/json.h
+++ b/src/shared/json.h
@@ -57,30 +57,32 @@ union json_value {
};
typedef struct JsonVariant {
+ JsonVariantType type;
+ size_t size;
union {
char *string;
struct JsonVariant *objects;
union json_value value;
};
- JsonVariantType type;
- unsigned size;
} JsonVariant;
int json_variant_new(JsonVariant **ret, JsonVariantType type);
-JsonVariant *json_variant_unref(JsonVariant *);
+JsonVariant *json_variant_unref(JsonVariant *v);
+
DEFINE_TRIVIAL_CLEANUP_FUNC(JsonVariant *, json_variant_unref);
-#define _cleanup_jsonunref_ _cleanup_(json_variant_unrefp)
+#define _cleanup_json_variant_unref_ _cleanup_(json_variant_unrefp)
-char *json_variant_string(JsonVariant *);
-bool json_variant_bool(JsonVariant *);
-intmax_t json_variant_integer(JsonVariant *);
-double json_variant_real(JsonVariant *);
+char *json_variant_string(JsonVariant *v);
+bool json_variant_bool(JsonVariant *v);
+intmax_t json_variant_integer(JsonVariant *v);
+double json_variant_real(JsonVariant *v);
-JsonVariant *json_variant_element(JsonVariant *, unsigned index);
-JsonVariant *json_variant_value(JsonVariant *, const char *key);
+JsonVariant *json_variant_element(JsonVariant *v, unsigned index);
+JsonVariant *json_variant_value(JsonVariant *v, const char *key);
#define JSON_VALUE_NULL ((union json_value) {})
int json_tokenize(const char **p, char **ret_string, union json_value *ret_value, void **state, unsigned *line);
+
int json_parse(const char *string, JsonVariant **rv);
int json_parse_measure(const char *string, size_t *size);