Casting JSONValues arrays to native arrays ... ??? ...

james.p.leblanc james.p.leblanc at gmail.com
Thu Sep 23 20:32:36 UTC 2021


On Thursday, 23 September 2021 at 19:18:11 UTC, james.p.leblanc 
wrote:
> On Thursday, 23 September 2021 at 19:04:47 UTC, Steven 
> Schveighoffer wrote:
>> On 9/23/21 2:20 PM, james.p.leblanc wrote:
>>> Dear D-ers,
>>> 

Here comes a minor update (small rearrangement in mapping/array 
ordering)
for anyone who may be interested.  With this small edit to the 
suggested code,
it works just fine!  Here:


  ```d

    auto z5 = jj["ba"].array.map!(v => v.get!bool);

    writeln("typeid(z5): ", typeid(z5), ", z5: ", z5);
    writeln("z5: ", z5);

```
Produces:

typeid(jj): std.json.JSONValue, jj: 
{"ba":[true,false,true],"d":[1.23399999999999999]}
typeid(z5): question.main.MapResult!(__lambda2, 
JSONValue[]).MapResult, z5: [true, false, true]
z5: [true, false, true]


Cheers,
James




More information about the Digitalmars-d-learn mailing list