Re: About the json output and the number of results shown.

Subject: Re: About the json output and the number of results shown.

Date: Sat, 29 Jan 2011 10:59:45 -0500

To: notmuch@notmuchmail.org

Cc:

From: Mike Kelly


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

> On Wed, 12 Jan 2011 22:39:45 +0000, Mike Kelly <pioto@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
signature.asc (application/pgp-signature)

Thread: