pascallouisperez / jsonmarshaller

JsonMarshaller is a Java 1.5 library that allows marshalling and unmarshalling of JSON objects to and from entities ("Java classes").
Apache License 2.0
1 stars 0 forks source link

Marshalling and unmarshalling of references #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This might be more of a feature request than of a bug report:

Assume you have the attached files. Note this: public User c = a;
You might expect it to marshall and unmarshall correctly so that c and a
are the same.

Expected output:

test.User@7919298d
test.User@62f72617
test.User@7919298d
{"a":{"name":"MyName","x":-1},"b":{"name":"MyName","x":-1},"c":{"name":"MyName",
"x":-1}}
test.User@33dff3a2
test.User@33f42b49
test.User@33dff3a2

Actual output:

test.User@7919298d
test.User@62f72617
test.User@7919298d
{"a":{"name":"MyName","x":-1},"b":{"name":"MyName","x":-1},"c":{"name":"MyName",
"x":-1}}
test.User@33dff3a2
test.User@33f42b49
test.User@6345e044

(Look at the last line of the examples)

It's quite obvious that it isn't unmarshalling so a and c are the same.

Suggestion to fix this:
Add some extra fields to use as metadata and put the actual object in an
other field named "data". References can be a type of metadata. Later when
unmarshalling it will detect the reference metadata and create the correct
reference.

Original issue reported on code.google.com by Jimmy.Ax...@gmail.com on 26 May 2010 at 8:27

Attachments:

GoogleCodeExporter commented 9 years ago
Oops, User.kava didnn't attach correctly!

Original comment by Jimmy.Ax...@gmail.com on 26 May 2010 at 8:31

Attachments:

GoogleCodeExporter commented 9 years ago
My guess is you uploaded the wrong file because n.a, n.b and b.c are int, not 
objects.

As per your feature/bug request, you are trying to push application concerns to 
a
serialisation library. That's just wrong. Serialisation libraries are meant to
convert to and from data, with no extra semantics.

Original comment by pascallo...@gmail.com on 26 May 2010 at 8:44