Fix simple serialization of sequences and maps
This commit is contained in:
parent
a1d8494de1
commit
e41a7f7014
2 changed files with 7 additions and 2 deletions
|
@ -14,6 +14,7 @@ use crate::sql::value::{value, Value};
|
|||
use nom::character::complete::char;
|
||||
use nom::combinator::opt;
|
||||
use nom::multi::separated_list0;
|
||||
use serde::ser::SerializeSeq;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
use std::fmt::{self, Display, Formatter, Write};
|
||||
|
@ -167,7 +168,11 @@ impl Serialize for Array {
|
|||
if is_internal_serialization() {
|
||||
serializer.serialize_newtype_struct(TOKEN, &self.0)
|
||||
} else {
|
||||
serializer.serialize_some(&self.to_string())
|
||||
let mut arr = serializer.serialize_seq(Some(self.len()))?;
|
||||
for v in &self.0 {
|
||||
arr.serialize_element(v)?;
|
||||
}
|
||||
arr.end()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ impl Serialize for Object {
|
|||
serializer.serialize_newtype_struct(TOKEN, &self.0)
|
||||
} else {
|
||||
let mut map = serializer.serialize_map(Some(self.len()))?;
|
||||
for (ref k, ref v) in &self.0 {
|
||||
for (k, v) in &self.0 {
|
||||
map.serialize_key(k)?;
|
||||
map.serialize_value(v)?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue