simd-json icon indicating copy to clipboard operation
simd-json copied to clipboard

Improve tests on serde interop

Open Licenser opened this issue 6 years ago • 2 comments

I honestly am lost in the forrest of serde traits, help would be appriciated.

Licenser avatar Oct 10 '19 17:10 Licenser

From what I understood of serde:

  • the Serialize and Deserialize traits are there to map a user type to an serde internal representation/data model.
  • the Serializer and Deserializer trait are there to map the serde data model to a external format. This is where the writing und parsing of the (file) format happens and where an external lib could be used to do that.

Having simd-json implements the Serialize and Deserialize traits for OwnedValue and BorrowedValue makes a DOM tree serializable to/deserializable from JSON using serde.

The implementation of the Deserializer trait means replacing the serde-json part that goes from JSON to serde data model by doing JSON --> Tape --> serde data model Then this serde data model can go to user defined types or to OwnedValue or BorrowedValue. This second path is clearly slower than going without serde with JSON --> OwnedValue/BorrowedValue

dvermd avatar Oct 25 '21 05:10 dvermd

Thanks! That's a nice explenation :). on the performance from we already solve that in a few ways, if we go str -> owned/borrowed Value we completely skip serde, it's mostly there so that people could do something like YAML -> Owned/Borrowed value or str -> their own struct (while to a degree simd_json_derive is a faster but less complete options here

Licenser avatar Oct 25 '21 09:10 Licenser