json icon indicating copy to clipboard operation
json copied to clipboard

Mention in documentation that Value can't represent all valid JSON data

Open tyilo opened this issue 1 year ago • 0 comments

Currently the README includes this text:

Any valid JSON data can be manipulated in the following recursive enum representation. This data structure is serde_json::Value.

enum Value {
    Null,
    Bool(bool),
    Number(Number),
    String(String),
    Array(Vec<Value>),
    Object(Map<String, Value>),
}

The documentation for serde_json::Value includes a similar statement.

However, this is not true as both

{
  "foo": "\ud800"
}

and

{
  "\ud800": "bar"
}

are valid JSON data but cannot be represented by the Value enum.

It would be nice to add a note explaining that invalid UTF-16 surrogate pairs are not supported.

tyilo avatar Aug 20 '24 12:08 tyilo