Help on asdf json module

Vino akashvino79 at
Mon Oct 26 09:43:44 UTC 2020

On Sunday, 25 October 2020 at 08:22:06 UTC, 9il wrote:
> On Sunday, 25 October 2020 at 06:05:27 UTC, Vino wrote:
>> Hi All,
>>    Currently we are testing various json module such as 
>> "std.json, std_data_json, and asdf", the below 
>> code works perfectely while use  "std_data_json or 
>>" but not working as expected when we use "asdf" 
>> and throwing the below error, hence request your help on the 
>> same.
>> [...]
> Hi Vino,
> byElement should be used here for ASDF.
> foreach(j; jv["items"].byElement)

Hi All,

   Thank you for your help, and now need your suggestion as the 
below code is working and it also prints an additional value 
which is not expected, so request your help on how to avoid the 
additional value,

import std.stdio: writeln;
import asdf: parseJson;
import std.conv: to;
import std.range: takeExactly;
import std.array: split;

void main()
  string apidata = `{"items":
     [{"Value":"D,dev at,DEV"},{"Value":"000"}]},
     [{"Value":"Q,qas at,QAS"},{"Value":"100"}]},
     [{"Value":"P,prd at,PRD"},{"Value":"100"}]}
  auto jv = parseJson(apidata);
  foreach(j; jv["items"].byElement()){
     foreach(i; j["type"].byElement().takeExactly(1)) {

dev at
qas at
prd at
[]   // additional value which is not expected


More information about the Digitalmars-d-learn mailing list