(other JSON)
| 405 | } |
| 406 | |
| 407 | func (j jsonString) Compare(other JSON) (int, error) { |
| 408 | cmp := cmpJSONTypes(j.Type(), other.Type()) |
| 409 | if cmp != 0 { |
| 410 | return cmp, nil |
| 411 | } |
| 412 | // TODO(justin): we should optimize this, we don't have to decode the whole thing. |
| 413 | var err error |
| 414 | if other, err = decodeIfNeeded(other); err != nil { |
| 415 | return 0, err |
| 416 | } |
| 417 | o := other.(jsonString) |
| 418 | if o > j { |
| 419 | return -1, nil |
| 420 | } |
| 421 | if o < j { |
| 422 | return 1, nil |
| 423 | } |
| 424 | return 0, nil |
| 425 | } |
| 426 | |
| 427 | func (j jsonArray) Compare(other JSON) (int, error) { |
| 428 | cmp := cmpJSONTypes(j.Type(), other.Type()) |
no test coverage detected