summaryrefslogtreecommitdiffstats
path: root/modules/md/md_json.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/md/md_json.c')
-rw-r--r--modules/md/md_json.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/modules/md/md_json.c b/modules/md/md_json.c
index fc7b13f8de..6feafa6d26 100644
--- a/modules/md/md_json.c
+++ b/modules/md/md_json.c
@@ -750,6 +750,16 @@ typedef struct {
apr_file_t *f;
} j_write_ctx;
+/* Convert from md_json_fmt_t to the Jansson json_dumpX flags. */
+static size_t fmt_to_flags(md_json_fmt_t fmt)
+{
+ /* NOTE: JSON_PRESERVE_ORDER is off by default before Jansson 2.8. It
+ * doesn't have any semantic effect on the protocol, but it does let the
+ * md_json_writeX unit tests run deterministically. */
+ return JSON_PRESERVE_ORDER |
+ ((fmt == MD_JSON_FMT_COMPACT) ? JSON_COMPACT : JSON_INDENT(2));
+}
+
static int dump_cb(const char *buffer, size_t len, void *baton)
{
apr_bucket_brigade *bb = baton;
@@ -761,8 +771,7 @@ static int dump_cb(const char *buffer, size_t len, void *baton)
apr_status_t md_json_writeb(md_json_t *json, md_json_fmt_t fmt, apr_bucket_brigade *bb)
{
- size_t flags = (fmt == MD_JSON_FMT_COMPACT)? JSON_COMPACT : JSON_INDENT(2);
- int rv = json_dump_callback(json->j, dump_cb, bb, flags);
+ int rv = json_dump_callback(json->j, dump_cb, bb, fmt_to_flags(fmt));
return rv? APR_EGENERAL : APR_SUCCESS;
}
@@ -778,12 +787,11 @@ static int chunk_cb(const char *buffer, size_t len, void *baton)
const char *md_json_writep(md_json_t *json, apr_pool_t *p, md_json_fmt_t fmt)
{
- size_t flags = (fmt == MD_JSON_FMT_COMPACT)? JSON_COMPACT : JSON_INDENT(2);
apr_array_header_t *chunks;
int rv;
chunks = apr_array_make(p, 10, sizeof(char *));
- rv = json_dump_callback(json->j, chunk_cb, chunks, flags);
+ rv = json_dump_callback(json->j, chunk_cb, chunks, fmt_to_flags(fmt));
if (rv) {
md_log_perror(MD_LOG_MARK, MD_LOG_ERR, 0, p,