(other JSON)
| 590 | } |
| 591 | |
| 592 | func (j *jsonEncoded) Compare(other JSON) (_ int, err error) { |
| 593 | if other == nil { |
| 594 | return -1, nil |
| 595 | } |
| 596 | // We must first check for the special case of empty arrays, which are the |
| 597 | // minimum JSON value. |
| 598 | switch { |
| 599 | case isEmptyArray(j) && isEmptyArray(other): |
| 600 | return 0, nil |
| 601 | case isEmptyArray(j): |
| 602 | return -1, nil |
| 603 | case isEmptyArray(other): |
| 604 | return 1, nil |
| 605 | } |
| 606 | if cmp := cmpJSONTypes(j.Type(), other.Type()); cmp != 0 { |
| 607 | return cmp, nil |
| 608 | } |
| 609 | // TODO(justin): this can be optimized in some cases. We don't necessarily |
| 610 | // need to decode all of an array or every object key. |
| 611 | dec, err := j.shallowDecode() |
| 612 | if err != nil { |
| 613 | return 0, err |
| 614 | } |
| 615 | return dec.Compare(other) |
| 616 | } |
| 617 | |
| 618 | func (j *jsonEncoded) Exists(key string) (bool, error) { |
| 619 | if dec := j.alreadyDecoded(); dec != nil { |
nothing calls this directly
no test coverage detected