Bug 3415 – broken JSON output

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86_64
OS
Linux
Creation time
2009-10-17T15:16:00Z
Last change time
2014-04-18T09:12:07Z
Keywords
patch
Assigned to
nobody
Creator
briancschott

Comments

Comment #0 by briancschott — 2009-10-17T15:16:41Z
Items in arrays output by the -X option of dmd are not properly separated by commas. The most common example of this is class member functions. Example: ... "members" : [ { "name" : "drawLayer", "kind" : "function", "type" : "void(uint layer, int x, int y)", "line" : 133} { "name" : "drawAllLayers", "kind" : "function", "type" : "void(int x, int y)", "line" : 149} ... Should read: ... "members" : [ { "name" : "drawLayer", "kind" : "function", "type" : "void(uint layer, int x, int y)", "line" : 133}, { "name" : "drawAllLayers", "kind" : "function", "type" : "void(int x, int y)", "line" : 149}, ... The lack of commas causes the resulting files to fail validation and attempts at parsing. See: http://www.jsonlint.com/
Comment #1 by ary — 2009-10-26T01:01:09Z
*** Issue 3440 has been marked as a duplicate of this issue. ***
Comment #2 by r.sagitario — 2010-04-14T00:04:47Z
This happens for declarations in an AttribDeclaration, where the code for adding commas is missing. Here's the patch: Index: json.c =================================================================== --- json.c (revision 432) +++ json.c (working copy) @@ -214,11 +214,17 @@ if (d) { + size_t offset = buf->offset; for (unsigned i = 0; i < d->dim; i++) { Dsymbol *s = (Dsymbol *)d->data[i]; + if (offset != buf->offset) + { buf->writestring(",\n"); + offset = buf->offset; + } //printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars()); s->toJsonBuffer(buf); } + JsonRemoveComma(buf); } }
Comment #3 by clugdbug — 2010-05-05T19:06:53Z
Fixed DMD2.044