RejectedSoftware Forums

Sign up

vibe.data.json seems a bit incomplete

So I've had a few practical problems with Json.
The one that's got me right now is that I can't see any way to mark members as @optional, or @noserialise, which means transient data ends up in files.
I've reached a show-stopper with it now though, where if I add a member to my struct, and then try and read my existing serialised data back into it, it complains that the new field is missing in the json and throws, so it destroys all my data any time I update a struct.
New fields that I add (not in the existing json data) should be able to take on default values.
Also it seems reasonable that omitting fields from the json is a reasonable request that the field should be set to default, which might help reduce data volume with unnecessary json fields set to default values.

Should I be using another serialisation library?

Re: vibe.data.json seems a bit incomplete

Am 21.11.2013 02:58, schrieb Manu Evans:

So I've had a few practical problems with Json.
The one that's got me right now is that I can't see any way to mark members as @optional, or @noserialise, which means transient data ends up in files.

It's @optional and @ignore in vibe.data.serialization

I've reached a show-stopper with it now though, where if I add a member to my struct, and then try and read my existing serialised data back into it, it complains that the new field is missing in the json and throws, so it destroys all my data any time I update a struct.
New fields that I add (not in the existing json data) should be able to take on default values.

-> @optional + use a field initializer

Also it seems reasonable that omitting fields from the json is a reasonable request that the field should be set to default, which might help reduce data volume with unnecessary json fields set to default values.

Should I be using another serialisation library?

Of course not! ;)

But seriously, Orange/std.serialization has some possibly interesting
features regarding data references. However, it doesn't support JSON
and, AFAIK, is not allocation-free (like the range based JSON
serialization in vibe.data.json), which may be an issue.

Re: vibe.data.json seems a bit incomplete

On Thu, 21 Nov 2013 13:01:27 +0100, Sönke Ludwig wrote:

Am 21.11.2013 02:58, schrieb Manu Evans:

So I've had a few practical problems with Json.
The one that's got me right now is that I can't see any way to mark members as @optional, or @noserialise, which means transient data ends up in files.

It's @optional and @ignore in vibe.data.serialization

Ah, of course it is!

Re: vibe.data.json seems a bit incomplete

Am 21.11.2013 15:49, schrieb Manu Evans:

On Thu, 21 Nov 2013 13:01:27 +0100, Sönke Ludwig wrote:

Am 21.11.2013 02:58, schrieb Manu Evans:

So I've had a few practical problems with Json.
The one that's got me right now is that I can't see any way to mark members as @optional, or @noserialise, which means transient data ends up in files.

It's @optional and @ignore in vibe.data.serialization

Ah, of course it is!

Will be there once the new version is released. (I'm also planning to
make GIT master docs and docs for older releases available eventually)

Re: vibe.data.json seems a bit incomplete

On 2013-11-21 01:58:11 +0000, Manu Evans said:

So I've had a few practical problems with Json.

The one that's got me right now is that I can't see any way to mark
members as @optional, or @noserialise, which means transient data ends
up in files.

I've reached a show-stopper with it now though, where if I add a member
to my struct, and then try and read my existing serialised data back
into it, it complains that the new field is missing in the json and
throws, so it destroys all my data any time I update a struct.

New fields that I add (not in the existing json data) should be able to
take on default values.

Also it seems reasonable that omitting fields from the json is a
reasonable request that the field should be set to default, which might
help reduce data volume with unnecessary json fields set to default
values.

Should I be using another serialisation library?

There is work being done on a much better std.json. I'm not sure how
much use updating this in vibe-d is right now.

https://github.com/Orvid/JSONSerialization