dtolnay / miniserde

Data structure serialization library with several opposite design goals from Serde

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON only => name the crate closer to json?

vi opened this issue · comments

Different: JSON only

Feature requests are practically guaranteed to be rejected.

That means, for example, there will be no CBOR (or something like that), which in turn means there will be no proper binary blob support. That probably limits usefullness of the library where it could be a good fit otherwise (e.g. something embedded).

As miniserde is intended to be locked to JSON, maybe it should be named after JSON instead, like minijson?

Thanks, this is a reasonable suggestion. I am still deliberating what direction to take this library and I intend to consider how to support other formats.

If you need similar functionality but for CBOR, it should be quite straightforward to fork this library and make it do CBOR instead. I don't know much about CBOR but from skimming some docs it looks like the two main differences would be:

  • Supporting bytestrings,
  • Supporting non-string keys.

Maybe with only one addition to the model (like this:)

@@ pub trait Visitor {

+    fn bytes(&mut self, s: &[u8]) -> Result<()> {
+        let _ = s;
+        Err(Error)
+   }

it can support CBOR alongside JSON?

If needed I can try to make a pull request, then it'll be more clear if overhead is small or not (so to merge it or to fork it). Having a fork has disadvantage that helper crates also needs to be duplicated.

That would address the deserialization side of bytestrings. You would need other changes to support serialization of bytestrings, deserialization of non-string keys, and serialization of non-string keys.

For now I would prefer to keep these changes out of miniserde.