Use the render function when doing string coercion for json values.

This commit is contained in:
Tom Alexander 2020-05-17 15:52:38 -04:00
parent 04d2f4b331
commit 4645530473
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -177,7 +177,15 @@ impl CompareContextElement for serde_json::Value {
// When doing a greater than or less than comparison, // When doing a greater than or less than comparison,
// javascript coerces objects into "[object Object]". // javascript coerces objects into "[object Object]".
if let serde_json::Value::Object(_) = self { if let serde_json::Value::Object(_) = self {
return OwnedLiteral::LString("[object Object]".to_owned()).partial_compare(other); return OwnedLiteral::LString(self.render(&Vec::new()).unwrap_or("".to_owned()))
.partial_compare(other);
}
// When doing a greater than or less than comparison
// javascript turns arrays into strings.
if let serde_json::Value::Array(_) = self {
return OwnedLiteral::LString(self.render(&Vec::new()).unwrap_or("".to_owned()))
.partial_compare(other);
} }
// Handle other serde_json::Value // Handle other serde_json::Value