git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
JHJeff Hostetler <git@jeffhostetler.com>
Date
Jun 11, 2018, 11:51 UTC
Message-ID
<eafb73e5-31f0-d34a-2179-6c4fef78656e@jeffhostetler.com>
In-Reply-To
<0690b5a8-6c1c-e664-bb89-5d4e48258ddb@web.de>
On 6/8/2018 4:07 PM, René Scharfe wrote:
> Am 07.06.2018 um 16:12 schrieb git@jeffhostetler.com:
>> From: Jeff Hostetler <jeffhost@microsoft.com>
[...]
Show 12 quoted lines
>> +	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

Previous: René ScharfeNext: René Scharfe
Message 8 of 13 in “json-writer V8”
  1. 0/2 json-writer V8git@jeffhostetler.com, Jun 7, 2018
  2. 1/2 json_writer: new routines to create data in JSON formatgit@jeffhostetler.com, Jun 7, 2018
  3. Eric SunshineJun 7, 2018
  4. Jeff HostetlerJun 8, 2018
  5. René ScharfeJun 8, 2018
  6. Jeff HostetlerJun 11, 2018
  7. René ScharfeJun 8, 2018
  8. Jeff HostetlerJun 11, 2018
  9. René ScharfeJun 8, 2018
  10. Jeff HostetlerJun 11, 2018
  11. 2/2 json-writer: t0019: add perl unit testgit@jeffhostetler.com, Jun 7, 2018
  12. Eric SunshineJun 7, 2018
  13. Jeff HostetlerJun 11, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.