About the json output and the number of results shown.

Mike Kelly pioto at pioto.org
Sat Jan 29 07:59:45 PST 2011


On Sat, 29 Jan 2011 06:44:40 +1000
Carl Worth <cworth at cworth.org> wrote:

> On Wed, 12 Jan 2011 22:39:45 +0000, Mike Kelly <pioto at pioto.org>
> wrote:
> > For starters, if I'm simply trying to retrieve a single message, the
> > interface is rather awkard. I seem to need to do something like:
> > 
> >     my $json = `notmuch show --format=json id:$message_id`;
> >     my $parsed_json = decode_json($json);
> >     my $message = $parsed_json->[0][0][0];
> 
> That does seem fairly awkward, yes. Do you have a suggestion for how
> you'd like the output to be structured instead?

Well, if I ask for a single message, I'd expect to just get a single
message. So, $message = $parsed_json, without the extra single-entry
arrays.

> > And, when I'm doing my search earlier to even find those message
> > ids, I need to do a check to `notmuch count` first to see if I'll
> > even get any results, because the 0 result case is not valid JSON.
> 
> Yikes! That's a bug in notmuch that we should get fixed rather than
> you just working around it. I just started adding a test for this
> case. Currently:
> 
> 	notmuch search --format=json "string that matches nothing"
> 
> returns nothing. Presumably, this should return just an empty json
> array instead, (that is, "[]")?

Yeah, should be "[]".

Thanks.

-- 
Mike Kelly
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110129/b19f2056/attachment.pgp>


More information about the notmuch mailing list