You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Usually serde_json can deserialize JSON strings into byte buffers, which makes deserializing JSON with lone surrogate pairs (which are valid JSON), possible (see #828).
Unfortunately, this is not possible when serde_json is driving the deserialization visitor, i.e. with deserialize_any. To my knowledge this makes it impossible to deserialize unknown JSON values while not erroring on lone surrogates using serde_json.
I understand this is rather contrived, but it'd be great to figure out a solution to this. I am not really sure how though. My best idea is to add a way for visitors to tell the Deserializer what visitation types it supports/prefers, so the Deserializer can make informed decisions about how to handle data types that can be deserialized in multiple ways in deserialize_any. This could look something like this:
typeVisitationType{Bool,Unsigned,Signed,Float,Char,String,Bytes,Unit,Option,NewtypeStruct,Seq,Map,Enum,}pubtraitVisitor<'de>:Sized{
...
/// Hint to the deserializer what types this visitor supports, for when the/// deserializer is driving the visitor autonomously using `deserialize_any`.////// This is only a hint. Deserializers are not required to respect the preference.fnpreferred_types(&self) -> Option<&[VisitationType]>{Some(&[])}}
This would require a change to serde though, which may not be desirable or possible.
I'd love to hear feedback on this.
The text was updated successfully, but these errors were encountered:
Usually
serde_json
can deserialize JSON strings into byte buffers, which makes deserializing JSON with lone surrogate pairs (which are valid JSON), possible (see #828).Unfortunately, this is not possible when
serde_json
is driving the deserialization visitor, i.e. withdeserialize_any
. To my knowledge this makes it impossible to deserialize unknown JSON values while not erroring on lone surrogates usingserde_json
.I understand this is rather contrived, but it'd be great to figure out a solution to this. I am not really sure how though. My best idea is to add a way for visitors to tell the
Deserializer
what visitation types it supports/prefers, so theDeserializer
can make informed decisions about how to handle data types that can be deserialized in multiple ways indeserialize_any
. This could look something like this:This would require a change to
serde
though, which may not be desirable or possible.I'd love to hear feedback on this.
The text was updated successfully, but these errors were encountered: