json_unstringify 2.0.0

Parse JSON that has been serialized as a JSON string
Documentation

json_unstringify

json_unstringify parses JSON that has been serialized as a JSON string. It also accepts regular JSON unchanged and safely handles multiple outer string layers.

let value = json_unstringify::parse("\"{\\\"name\\\":\\\"Ada\\\"}\"")?;
assert_eq!(value["name"], "Ada");
# Ok::<(), json_unstringify::Error>(())

The crate returns Result<serde_json::Value, json_unstringify::Error>. Malformed input is reported as an error; it never panics.

Migration from 1.x

parse now returns a Result instead of panicking on invalid input:

let value = json_unstringify::parse(input)?;

The implementation now uses serde_json to decode JSON string escaping, rather than applying regular-expression replacements. This preserves escaped characters and Unicode correctly.