Create an empty json object with std.json
userABCabc123 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 22 09:34:58 PST 2016
On Friday, 22 January 2016 at 16:58:51 UTC, Andrea Fontana wrote:
> On Friday, 22 January 2016 at 16:45:22 UTC, userABCabc123 wrote:
>> But soon or later you'll need to add values to your object so
>> just imagine it's already an object, even if it will only
>> become one when you'll start to add some values.
>
> You're wrong, I need an empty object for an API call!
>
> Moreover "{}" it's a valid json object and there's no easy way
> to create it using std.json.
It's true that it can be problematic, for example with an input
contract, or for subtyping a JSONValue as something like struct
JSONValueThatAlwayObject{}...
But there is only 3 ways in std.json, from a literal, using the
deprecated way or the "lazy" way.
More information about the Digitalmars-d-learn
mailing list