Use the render function when doing string coercion for json values.
This commit is contained in:
parent
04d2f4b331
commit
4645530473
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,
|
||||
// javascript coerces objects into "[object Object]".
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user