(other JSON)
| 698 | } |
| 699 | |
| 700 | func (j jsonString) Compare(other JSON) (int, error) { |
| 701 | if isEmptyArray(other) { |
| 702 | return 1, nil |
| 703 | } |
| 704 | cmp := cmpJSONTypes(j.Type(), other.Type()) |
| 705 | if cmp != 0 { |
| 706 | return cmp, nil |
| 707 | } |
| 708 | // TODO(justin): we should optimize this, we don't have to decode the whole thing. |
| 709 | var err error |
| 710 | if other, err = decodeIfNeeded(other); err != nil { |
| 711 | return 0, err |
| 712 | } |
| 713 | o := other.(jsonString) |
| 714 | if o > j { |
| 715 | return -1, nil |
| 716 | } |
| 717 | if o < j { |
| 718 | return 1, nil |
| 719 | } |
| 720 | return 0, nil |
| 721 | } |
| 722 | |
| 723 | func (j jsonArray) Compare(other JSON) (int, error) { |
| 724 | switch { |
no test coverage detected