rust-embedded-community / serde-json-core

`serde-json` for `no_std` programs
Apache License 2.0
161 stars 59 forks source link

String escaping #30

Closed webmaster128 closed 3 years ago

webmaster128 commented 4 years ago

As documented in https://github.com/japaric/serde-json-core/blob/238c8fe/src/lib.rs#L46, strings are not escaped in serialization. This leads to broken JSON results when e.g. a " character exists as part of the string content.

If someone wants to tackle this, feel free to copy the implementation from https://github.com/CosmWasm/serde-json-wasm/pull/10.

You probably need to work on unescaping at the same time (which is hard and not zero-copy) if you want deserialize(serialize(original)) == original. For a seralize-only use case however, escaping is an important independent step.