How to parse JSON in D?

tastyminerals tastyminerals at gmail.com
Mon Mar 29 17:21:25 UTC 2021


We need to parse a bunch of JSON files. What does D have? It has 
std.json which is strangely slower than Python json :(
Ok, we go to dub repository and search for something that is 
faster. There are basically two implementations fast.json and 
stdx.data.json. The first one refuses to work on Mac M1 chip so 
we take the stdx.data.json, go to the documentation page and see 
two three snippets on how to use the library. The code examples 
are so scarce that I feel like a person who did it was forced to 
do it out of his own will.

Now, to the problem. I have the following JSON structure.

"items": {
"elements": [
    {
      "name" : "",
      "type" : ""
    },
    {
      "name": "",
      "type": ""
    }
   ]
}

auto elements = parseJSONValue("file.json")["items]["elements"];

I want to access each "name" member of "elements". How do I do it 
in stdx.data.json?


More information about the Digitalmars-d-learn mailing list