X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-reply.c;h=e60a264b5d30acf8cec96412f17e150789e43c5c;hp=3a038ed75a06c0a4f76a847f344fec4c94641d53;hb=90cd1bac4eeb0d57fbe2740625aaa58d8d925ee5;hpb=e04b18cf3624e1ba29a45cd1f15715e1da244021 diff --git a/notmuch-reply.c b/notmuch-reply.c index 3a038ed7..e60a264b 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -22,6 +22,7 @@ #include "notmuch-client.h" #include "gmime-filter-headers.h" +#include "sprinter.h" static void show_reply_headers (GMimeMessage *message) @@ -596,6 +597,7 @@ notmuch_reply_format_json(void *ctx, notmuch_messages_t *messages; notmuch_message_t *message; mime_node_t *node; + sprinter_t *sp; if (notmuch_query_count_messages (query) != 1) { fprintf (stderr, "Error: search term did not match precisely one message.\n"); @@ -611,19 +613,21 @@ notmuch_reply_format_json(void *ctx, if (!reply) return 1; + sp = sprinter_json_create (ctx, stdout); + sp->begin_map (sp); + /* The headers of the reply message we've created */ - printf ("{\"reply-headers\": "); - format_headers_json (ctx, reply, TRUE); + sp->map_key (sp, "reply-headers"); + format_headers_json (sp, reply, TRUE); g_object_unref (G_OBJECT (reply)); reply = NULL; /* Start the original */ - printf (", \"original\": "); - - format_part_json (ctx, node, TRUE); + sp->map_key (sp, "original"); + format_part_json (ctx, sp, node, TRUE, TRUE); /* End */ - printf ("}\n"); + sp->end (sp); notmuch_message_destroy (message); return 0;