jcrist / msgspec

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
https://jcristharif.com/msgspec/
BSD 3-Clause "New" or "Revised" License
2.45k stars 76 forks source link

JSON support? #8

Closed jcrist closed 2 years ago

jcrist commented 3 years ago

The schema handling logic and struct objects aren't MessagePack specific, and could be adopted for other protocols. This would allow an application to switch between JSON and MessagePack, while making use of the same schemas and objects throughout. I don't plan on working on this anytime soon, but adding support for JSON here isn't unreasonable. Unlike MessagePack though, parsing JSON is nontrivial, so adding support would require some care.

jcrist commented 3 years ago

I no longer think this makes sense (at least for now). With the addition of extension types (and encoder hooks), there is enough msgpack specific things in here that anything json-specific would likely best be handled in a separate repo.

jcrist commented 3 years ago

Actually, I am going to reopen this. Except for msgspec.Ext, everything here still applies to json.

adriangb commented 3 years ago

It could be nice to have something like Pydantic but where the model and validation definition are completely separate from the serialization protocol so that the serialization can be a pluggable piece.