handle leading space in array strings

This commit is contained in:
Robin Appelman 2023-12-19 19:44:17 +01:00
commit 63b3bdbefd
5 changed files with 7 additions and 8 deletions

View file

@ -573,7 +573,7 @@ impl<'de> Deserializer<'de> for Entry {
where
V: Visitor<'de>,
{
match dbg!(self) {
match self {
Entry::Array(arr) => visitor.visit_seq(ArraySeq::new(arr)),
_ => Err(UnknownError::from("array2").into()),
}
@ -583,7 +583,7 @@ impl<'de> Deserializer<'de> for Entry {
where
V: Visitor<'de>,
{
match dbg!(self) {
match self {
Entry::Array(arr) => visitor.visit_seq(ArraySeq::new(arr)),
_ => Err(UnknownError::from("tuple").into()),
}

View file

@ -71,12 +71,12 @@ impl Table {
value,
..
}) => {
if string_is_array(value.as_str()) {
let str = value.as_str();
if string_is_array(str) {
insert(
&mut map,
key,
Array::from_space_separated(&str[1..str.len() - 1]),
Array::from_space_separated(str[1..str.len() - 1].trim()),
)
} else {
insert(&mut map, key, Value::from(value.into_content()))

View file

@ -315,7 +315,6 @@ impl<'de> Deserializer<'de> for Value {
where
V: Visitor<'de>,
{
dbg!(&self);
Err(SerdeParseError::new("seq", self.0.as_ref(), 0..0, "").into())
}

View file

@ -354,7 +354,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|| (value_str.starts_with("\"{") && value_str.ends_with("}\""))
{
let _ = self.next();
let seq = &value_str[2..value_str.len() - 2];
let seq = &value_str[2..value_str.len() - 2].trim();
let span = token.span.start + 2..token.span.end - 2;
visitor.visit_seq(StringArrayWalker::new(self.source(), seq, span))
} else {

View file

@ -1,7 +1,7 @@
"Types" {
fixed_array "[1 2 3]"
flex_array "[1.0 2.2]"
tuple "[1 57]"
tuple "[ 1 57]"
single 1.2
triple "{1.2 1.3 1.4}"
single_int 2