Web lists-archives.com

Re: [PATCH v8 1/2] json_writer: new routines to create data in JSON format






On 6/8/2018 4:07 PM, René Scharfe wrote:
Am 07.06.2018 um 16:12 schrieb git@xxxxxxxxxxxxxxxxx:
From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx>
[...]
+	if (jw->first_stack.buf[jw->first_stack.len - 1] == '1')
+		jw->first_stack.buf[jw->first_stack.len - 1] = '0';
+	else
+		strbuf_addch(&jw->json, ',');

You only need a binary flag to indicate if a comma is needed, not a
stack.  We need a comma at the current level if and only if we already
wrote a child item.  If we finish a level then we do need a comma at the
previous level because we just wrote a sub-object or sub-array there.
And that should cover all cases.  Am I missing something?

I get a sense of déjà vu, by the way. :)
[...]

Yes, your way is simpler.  I'll update and re-roll.
(And yes, we did discuss this earlier.  I found a problem with
my first version where it wouldn't handle empty sub-items, but
you found the missing piece.)

Thanks
Jeff