Yuri wrote:
On Monday, 3 July 2017 at 14:04:47 UTC, ketmar wrote:
Yuri wrote:
On Sunday, 2 July 2017 at 21:15:41 UTC, ketmar wrote:
[...]
I share your sentiment in relation to std.json, ketmar.
On a side note, what would be a better way to serialize/deserialize
objects in D if std.json does not cut it? It does not have to be JSON
serialization although would be preferred.
it depends of the types of your objects. simple json-like (de)serializer
for objects with fixed layout can be done in very small amount of
code[0]. that's what i am using (and it can *read* json into structs
too, i'm actually using it to parse some jsons -- idgames API replies,
for example).
[0] http://repo.or.cz/iv.d.git/blob_plain/HEAD:/txtser.d
Thanks, ketmar, I'll have a look into the code, the objects I am dealing
with are not particularly complex, that might work well enough.
it doesn't matter if objects are complex or not; the only thing that
matters is that you must really have *objects* that can be described by
structs, not "freeform" json. i.e. txtser cannot deserialize json into
dom-like tree structure, only deserialize structs/arrays/aas.
but structs can contain other structs, and AA values can be structs too,
and so on.
i.e.: if you don't need arbitrary access to arbitrary json fields, but only
have to deserialize something with known layout, txtser probably can do the
job for you.