aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/json.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/json.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/json.c b/src/json.c
index 10b34a9..2909c74 100644
--- a/src/json.c
+++ b/src/json.c
@@ -17,9 +17,9 @@
#include <stdlib.h>
#include <string.h>
-const char *json_to_string(struct json_object *obj)
+static const char *json_to_string_internal(struct json_object *obj, int flags)
{
- const char *result = json_object_to_json_string(obj);
+ const char *result = json_object_to_json_string_ext(obj, flags);
if (!result) {
json_errno("json_object_to_json_string");
return NULL;
@@ -27,6 +27,16 @@ const char *json_to_string(struct json_object *obj)
return result;
}
+const char *json_to_string(struct json_object *obj)
+{
+ return json_to_string_internal(obj, JSON_C_TO_STRING_SPACED);
+}
+
+const char *json_to_string_pretty(struct json_object *obj)
+{
+ return json_to_string_internal(obj, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY);
+}
+
struct json_object *json_from_string(const char *src)
{
enum json_tokener_error error;