(other JSON)
| 475 | } |
| 476 | |
| 477 | func (j jsonArray) Compare(other JSON) (int, error) { |
| 478 | cmp := cmpJSONTypes(j.Type(), other.Type()) |
| 479 | if cmp != 0 { |
| 480 | return cmp, nil |
| 481 | } |
| 482 | lenJ := j.Len() |
| 483 | lenO := other.Len() |
| 484 | if lenJ < lenO { |
| 485 | return -1, nil |
| 486 | } |
| 487 | if lenJ > lenO { |
| 488 | return 1, nil |
| 489 | } |
| 490 | // TODO(justin): we should optimize this, we don't have to decode the whole thing. |
| 491 | var err error |
| 492 | if other, err = decodeIfNeeded(other); err != nil { |
| 493 | return 0, err |
| 494 | } |
| 495 | o := other.(jsonArray) |
| 496 | for i := 0; i < lenJ; i++ { |
| 497 | cmp, err := j[i].Compare(o[i]) |
| 498 | if err != nil { |
| 499 | return 0, err |
| 500 | } |
| 501 | if cmp != 0 { |
| 502 | return cmp, nil |
| 503 | } |
| 504 | } |
| 505 | return 0, nil |
| 506 | } |
| 507 | |
| 508 | func (j jsonObject) Compare(other JSON) (int, error) { |
| 509 | cmp := cmpJSONTypes(j.Type(), other.Type()) |
nothing calls this directly
no test coverage detected