Skip to content

Commit

Permalink
Merge pull request #174 from haata/master
Browse files Browse the repository at this point in the history
Adding JSON_C_TO_STRING_PRETTY_TAB flag
  • Loading branch information
hawicz committed May 31, 2015
2 parents cd8bd7f + 92d4cf1 commit b594c34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion json_object.c
Expand Up @@ -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);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions json_object.h
Expand Up @@ -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
*/
Expand Down

0 comments on commit b594c34

Please sign in to comment.