Save JSONValue binary in file?

Piotr Szturmaj bncrbme at jadamspam.pl
Fri Oct 12 10:33:30 PDT 2012


Chopin wrote:
> Thanks! I tried using it:
>
> auto document = parseJSON(content).array; // this works with std.json :)
>
> Using json.d from the link:
>
> auto j = JSONReader!string(content);
> auto document = j.value.whole.array; // this doesn't.... "Error:
> undefined identifier 'array'"

If you're sure that content is an array:

auto j = JSONReader!string(content);
auto jv = j.value.whole;
assert(jv.type == JSONType.array);
auto jsonArray = jv.as!(JSONValue[]);

alternatively you can replace last line with

alias JSONValue[] JSONArray;
auto jsonArray = jv.as!JSONArray;


More information about the Digitalmars-d-learn mailing list