If an array with a single value is serialized into XML and then converted into JSON it stops being an array and becomes a value or an object. Then it fails to deserialize into Vec or any other collection type. Examples:
<a>
<b>1</b>
<b>2</b>
</a>
becomes
"a": {
"b": [1,2]
}
and can be deserialized into Vec<i64>, but
<a>
<b>1</b>
</a>
becomes
"a": {
"b": 1
}
and fails if we try to put it into the same Vec<i64> type.
Proposed solution
Add JsonType::Array to enforce an array on the mapped XML elements the same way we enforce other types
Allow mixing JsonType::Array with other types, e.g. JsonType::AlwaysString so that
<a>
<b>1</b>
</a>
becomes
"a": { "b": [1] }
with Infer or
"a": { "b": ["1"] }
with AlwaysString
This will be an extension to recently merged type enforcement, which is an optional feature and will affect existing implementations.
@AlecTroemel , Alec, do you have a minute to review this? Does it make sense? Am I on the right path here?
If an array with a single value is serialized into XML and then converted into JSON it stops being an array and becomes a value or an object. Then it fails to deserialize into
Vec
or any other collection type. Examples:becomes
and can be deserialized into
Vec<i64>
, butbecomes
and fails if we try to put it into the same
Vec<i64>
type.Proposed solution
Add
JsonType::Array
to enforce an array on the mapped XML elements the same way we enforce other typesAllow mixing
JsonType::Array
with other types, e.g.JsonType::AlwaysString
so thatbecomes
with
Infer
orwith
AlwaysString
This will be an extension to recently merged type enforcement, which is an optional feature and will affect existing implementations.
@AlecTroemel , Alec, do you have a minute to review this? Does it make sense? Am I on the right path here?