summaryrefslogtreecommitdiffstats
path: root/vendor/serde_json/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/serde_json/src')
-rw-r--r--vendor/serde_json/src/de.rs39
-rw-r--r--vendor/serde_json/src/lib.rs2
-rw-r--r--vendor/serde_json/src/ser.rs17
-rw-r--r--vendor/serde_json/src/value/de.rs20
-rw-r--r--vendor/serde_json/src/value/ser.rs4
5 files changed, 73 insertions, 9 deletions
diff --git a/vendor/serde_json/src/de.rs b/vendor/serde_json/src/de.rs
index 7f3145980..9975b40a5 100644
--- a/vendor/serde_json/src/de.rs
+++ b/vendor/serde_json/src/de.rs
@@ -2203,6 +2203,41 @@ where
deserialize_numeric_key!(deserialize_f32, deserialize_f32);
deserialize_numeric_key!(deserialize_f64);
+ fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value>
+ where
+ V: de::Visitor<'de>,
+ {
+ self.de.eat_char();
+
+ let peek = match tri!(self.de.next_char()) {
+ Some(b) => b,
+ None => {
+ return Err(self.de.peek_error(ErrorCode::EofWhileParsingValue));
+ }
+ };
+
+ let value = match peek {
+ b't' => {
+ tri!(self.de.parse_ident(b"rue\""));
+ visitor.visit_bool(true)
+ }
+ b'f' => {
+ tri!(self.de.parse_ident(b"alse\""));
+ visitor.visit_bool(false)
+ }
+ _ => {
+ self.de.scratch.clear();
+ let s = tri!(self.de.read.parse_str(&mut self.de.scratch));
+ Err(de::Error::invalid_type(Unexpected::Str(&s), &visitor))
+ }
+ };
+
+ match value {
+ Ok(value) => Ok(value),
+ Err(err) => Err(self.de.fix_position(err)),
+ }
+ }
+
#[inline]
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value>
where
@@ -2258,7 +2293,7 @@ where
}
forward_to_deserialize_any! {
- bool char str string unit unit_struct seq tuple tuple_struct map struct
+ char str string unit unit_struct seq tuple tuple_struct map struct
identifier ignored_any
}
}
@@ -2406,7 +2441,7 @@ where
if self_delineated_value {
Ok(value)
} else {
- self.peek_end_of_value().map(|_| value)
+ self.peek_end_of_value().map(|()| value)
}
}
Err(e) => {
diff --git a/vendor/serde_json/src/lib.rs b/vendor/serde_json/src/lib.rs
index c322ed8a4..83f48a031 100644
--- a/vendor/serde_json/src/lib.rs
+++ b/vendor/serde_json/src/lib.rs
@@ -300,7 +300,7 @@
//! [macro]: crate::json
//! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core
-#![doc(html_root_url = "https://docs.rs/serde_json/1.0.104")]
+#![doc(html_root_url = "https://docs.rs/serde_json/1.0.105")]
// Ignored clippy lints
#![allow(
clippy::collapsible_else_if,
diff --git a/vendor/serde_json/src/ser.rs b/vendor/serde_json/src/ser.rs
index 6bb6fd761..3742e0bef 100644
--- a/vendor/serde_json/src/ser.rs
+++ b/vendor/serde_json/src/ser.rs
@@ -827,8 +827,21 @@ where
type SerializeStruct = Impossible<(), Error>;
type SerializeStructVariant = Impossible<(), Error>;
- fn serialize_bool(self, _value: bool) -> Result<()> {
- Err(key_must_be_a_string())
+ fn serialize_bool(self, value: bool) -> Result<()> {
+ tri!(self
+ .ser
+ .formatter
+ .begin_string(&mut self.ser.writer)
+ .map_err(Error::io));
+ tri!(self
+ .ser
+ .formatter
+ .write_bool(&mut self.ser.writer, value)
+ .map_err(Error::io));
+ self.ser
+ .formatter
+ .end_string(&mut self.ser.writer)
+ .map_err(Error::io)
}
fn serialize_i8(self, value: i8) -> Result<()> {
diff --git a/vendor/serde_json/src/value/de.rs b/vendor/serde_json/src/value/de.rs
index 2090dd009..1e8b5acbb 100644
--- a/vendor/serde_json/src/value/de.rs
+++ b/vendor/serde_json/src/value/de.rs
@@ -1183,6 +1183,22 @@ impl<'de> serde::Deserializer<'de> for MapKeyDeserializer<'de> {
deserialize_numeric_key!(deserialize_i128, do_deserialize_i128);
deserialize_numeric_key!(deserialize_u128, do_deserialize_u128);
+ fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Error>
+ where
+ V: Visitor<'de>,
+ {
+ if self.key == "true" {
+ visitor.visit_bool(true)
+ } else if self.key == "false" {
+ visitor.visit_bool(false)
+ } else {
+ Err(serde::de::Error::invalid_type(
+ Unexpected::Str(&self.key),
+ &visitor,
+ ))
+ }
+ }
+
#[inline]
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Error>
where
@@ -1219,8 +1235,8 @@ impl<'de> serde::Deserializer<'de> for MapKeyDeserializer<'de> {
}
forward_to_deserialize_any! {
- bool char str string bytes byte_buf unit unit_struct seq tuple
- tuple_struct map struct identifier ignored_any
+ char str string bytes byte_buf unit unit_struct seq tuple tuple_struct
+ map struct identifier ignored_any
}
}
diff --git a/vendor/serde_json/src/value/ser.rs b/vendor/serde_json/src/value/ser.rs
index 6ca53d4c5..835fa9080 100644
--- a/vendor/serde_json/src/value/ser.rs
+++ b/vendor/serde_json/src/value/ser.rs
@@ -483,8 +483,8 @@ impl serde::Serializer for MapKeySerializer {
value.serialize(self)
}
- fn serialize_bool(self, _value: bool) -> Result<String> {
- Err(key_must_be_a_string())
+ fn serialize_bool(self, value: bool) -> Result<String> {
+ Ok(value.to_string())
}
fn serialize_i8(self, value: i8) -> Result<String> {