Annotation of functions

psychoticRabbit meagain at meagain.com
Thu Feb 22 11:54:06 UTC 2018


On Thursday, 22 February 2018 at 11:32:59 UTC, rjframe wrote:
> On Thu, 22 Feb 2018 10:41:48 +0000, psychoticRabbit wrote:
>
>> On Tuesday, 20 February 2018 at 15:26:12 UTC, Adam D. Ruppe 
>> wrote:
>>> dmd -X spits out the json file with a list of functions and 
>>> classes and other stuff. Then you can just filter that.
>> 
>> do you know why the first and last character of the output 
>> from "dmd -o- -X somefile.d" are [  and  ] with all the json 
>> inbetween.
>> 
>> I'm don't really know json (never had a need to know) but as I 
>> try different json parsers, the first thing I have to do 
>> (before giving it to the json parser), is strip off the first 
>> and last character of that output.
>> 
>> so why put them there in the first place, is my question.
>
> They form an array.
>
> `[1, 2, 3]` is an array of numbers, and `[{"a":1}, {"b":2}, 
> {"c":3}]` is an array of objects.

here is my point though:

=============
module test;

import std.stdio, std.file, std.json;

void main()
{
     string myFile= "source.json"; // a file produced by: dmd -o- 
-X source.d

     string js = readText(myFile);

     JSONValue j = parseJSON( js[1..$-1] ); // why do I have to do 
this??

     writefln("%s = %s", j["kind"].str, j["name"].str);
     writefln("file = %s", j["file"].str);

}
==============


More information about the Digitalmars-d mailing list