]> git.notmuchmail.org Git - notmuch/commitdiff
reply: Convert JSON format to use sprinter
authorAustin Clements <amdragon@MIT.EDU>
Tue, 7 Aug 2012 12:57:10 +0000 (08:57 -0400)
committerDavid Bremner <bremner@debian.org>
Sun, 12 Aug 2012 19:29:38 +0000 (21:29 +0200)
Almost all of reply was already being formatted using the sprinter.
This patch converts the top-level dictionary to use the sprinter
interface.

notmuch-reply.c

index fa6665f7191572d84e4c41ce535330ae4199090e..e60a264b5d30acf8cec96412f17e150789e43c5c 100644 (file)
@@ -614,20 +614,20 @@ notmuch_reply_format_json(void *ctx,
        return 1;
 
     sp = sprinter_json_create (ctx, stdout);
+    sp->begin_map (sp);
 
     /* The headers of the reply message we've created */
-    printf ("{\"reply-headers\": ");
+    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\": ");
-
+    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;