]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Adding JSON_C_TO_STRING_PRETTY_TAB flag 174/head
authorJacob Alexander <jacob.alexander@virtualinstruments.com>
Mon, 23 Mar 2015 23:34:30 +0000 (16:34 -0700)
committerJacob Alexander <jacob.alexander@virtualinstruments.com>
Thu, 28 May 2015 00:37:39 +0000 (17:37 -0700)
- Tabs are easier to read for tired eyes and editor adjustable

json_object.c
json_object.h

index 9b89bb7673ac2798cbb2a33bfc319214d03203f1..48d3850d588a70aaaa955d336201edcee1f770db 100644 (file)
@@ -300,7 +300,14 @@ static void indent(struct printbuf *pb, int level, int flags)
 {
        if (flags & JSON_C_TO_STRING_PRETTY)
        {
-               printbuf_memset(pb, -1, ' ', level * 2);
+               if (flags & JSON_C_TO_STRING_PRETTY_TAB)
+               {
+                       printbuf_memset(pb, -1, '\t', level);
+               }
+               else
+               {
+                       printbuf_memset(pb, -1, ' ', level * 2);
+               }
        }
 }
 
index 2bdfd5f9d6851c00ec72f92a1230f4dfb8f6edf9..5e0cf7143441ddefa07bd3e98d407357c56b88c4 100644 (file)
@@ -50,6 +50,14 @@ extern "C" {
  * for an example of the format.
  */
 #define JSON_C_TO_STRING_PRETTY     (1<<1)
+/**
+ * A flag for the json_object_to_json_string_ext() and
+ * json_object_to_file_ext() functions which causes
+ * the output to be formatted.
+ *
+ * Instead of a "Two Space Tab" this gives a single tab character.
+ */
+#define JSON_C_TO_STRING_PRETTY_TAB (1<<3)
 /**
  * A flag to drop trailing zero for float values
  */