From 88943b64e35c01e170e2ccb242b07e97a91b5816 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Mon, 7 Jul 2014 11:29:10 +0300 Subject: [PATCH] Define JSON_MAX_INDENT Fixes #191. --- doc/apiref.rst | 6 ++++++ src/jansson.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/apiref.rst b/doc/apiref.rst index 9c29c79..f8c27f7 100644 --- a/doc/apiref.rst +++ b/doc/apiref.rst @@ -866,6 +866,12 @@ can be ORed together to obtain *flags*. output. If ``JSON_INDENT`` is not used or *n* is 0, no newlines are inserted between array and object items. + The ``JSON_MAX_INDENT`` constant defines the maximum indentation + that can be used, and its value is 31. + + .. versionchanged:: 2.7 + Added ``JSON_MAX_INDENT``. + ``JSON_COMPACT`` This flag enables a compact representation, i.e. sets the separator between array and object items to ``","`` and between object keys diff --git a/src/jansson.h b/src/jansson.h index bcb2087..80ab05f 100644 --- a/src/jansson.h +++ b/src/jansson.h @@ -259,7 +259,8 @@ json_t *json_load_callback(json_load_callback_t callback, void *data, size_t fla /* encoding */ -#define JSON_INDENT(n) ((n) & 0x1F) +#define JSON_MAX_INDENT 0x1F +#define JSON_INDENT(n) ((n) & JSON_MAX_INDENT) #define JSON_COMPACT 0x20 #define JSON_ENSURE_ASCII 0x40 #define JSON_SORT_KEYS 0x80