Casting JSONValues arrays to native arrays ... ??? ...
james.p.leblanc
james.p.leblanc at gmail.com
Thu Sep 23 19:18:11 UTC 2021
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,
>>
>> In attempting to cast JSONValues that hold arrays to "native"
> How you really do this:
>
> ```d
> import std.algorithm : map;
> auto z5 = jj["ba"] // get the JSONValue that is at the key "ba"
> .map!(v => v.get!bool) // map each value into a boolean
> .array // create an array out of the results;
> assert z5 == [true, false, true];
> ```
>
> (warning, untested)
>
> -Steve
Steve,
Your thorough explanations have helped me understand quite much.
Thank you for your energy and patience in these forum
contributions.
In fact, I had begun to think that "map", may be what was needed
here
and I had made a few naive attempts ... but this did not go so
well.
With your suggested solution, I believe I can make headway on
this.
Thanks Again,
James
More information about the Digitalmars-d-learn
mailing list