owlike / genson

Genson a fast & modular Java <> Json library
http://owlike.github.io/genson/
218 stars 66 forks source link

wrong primitive array serialization with useClassMetadata(true) #149

Open roli8200 opened 4 years ago

roli8200 commented 4 years ago

When serializing a array of primitives int[], String[], byte[], etc. the expected output should be something like:

{ "@class":"int[]","data":[2,25,10]  }

instead i get this

[
  2,
  25,
  10,
]

or for byte[] { "@class":"byte[]",data:"3JugnGCdJJ3onqyf..." } i get this

"3JugnGCdJJ3onqyf.......

Since these (arrays) are not real classes, direct naming of a class is difficult, but there should still be a (syntetic) annotation that describes the data type exactly, since these must also be deserialized correctly again, especially in terms of polymorphic deserialization.

EugenCepoi commented 4 years ago

Please provide a self contained executable code that I can use to reproduce that. I’m mostly interested in seeing what confit you use for Genson.

On Aug 21, 2019, at 3:03 AM, roli8200 notifications@github.com wrote:

When serializing a array of primitives int[], String[], byte[], etc. the expected output should be something like:

{ "@class":"int[]","data":[2,25,10] } instead i get this

[ 2, 25, 10, ] or for byte[] { "@class":"byte[]",data:"3JugnGCdJJ3onqyf..." } i get this

"3JugnGCdJJ3onqyf.......

Since these (arrays) are not real classes, direct naming of a class is difficult, but there should still be a (syntetic) annotation that describes the data type exactly, since these must also be deserialized correctly again, especially in terms of polymorphic deserialization.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.