Use the render function when doing string coercion for json values.
This commit is contained in:
10
src/bin.rs
10
src/bin.rs
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user