Open AlexanderZhirov opened 1 year ago
auto allows = jsr["allows"].get!array;
auto allows = jsr["allows"].get!Json[];
This should be jsr["allows"].get!(Json[])
- and .get!(Json[string])
for reading JSON objects. It's missing the parenthesis, so that the []
applies to the return value of get()
instead of being part of the requested type.
In general, you can serialize any D type to JSON using vibe.data.json.serializeToJson
(or serializeToPrettyJson
). Some types may need to be adjusted using custom toJson
and fromJson
methods to get a usable result, but most types work as-is. Similarly, if the JSON format is fixed, deserializeJson
would be the quick way to parse JSON back into
How to properly receive JSON and send it, given that I do it this way?
How to read the array that is inside? It is not possible to lead to the desired type, writes errors.
There are no examples in the documentation of how to get an array in the desired format.
Are there any clearer examples about converting a large number of variables to Json? Without using prepared structures.