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/
*** Issue 3440 has been marked as a duplicate of this issue. ***
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); } }
Fixed DMD2.044