(other JSON)
| 425 | } |
| 426 | |
| 427 | func (j jsonArray) Compare(other JSON) (int, error) { |
| 428 | cmp := cmpJSONTypes(j.Type(), other.Type()) |
| 429 | if cmp != 0 { |
| 430 | return cmp, nil |
| 431 | } |
| 432 | lenJ := j.Len() |
| 433 | lenO := other.Len() |
| 434 | if lenJ < lenO { |
| 435 | return -1, nil |
| 436 | } |
| 437 | if lenJ > lenO { |
| 438 | return 1, nil |
| 439 | } |
| 440 | // TODO(justin): we should optimize this, we don't have to decode the whole thing. |
| 441 | var err error |
| 442 | if other, err = decodeIfNeeded(other); err != nil { |
| 443 | return 0, err |
| 444 | } |
| 445 | o := other.(jsonArray) |
| 446 | for i := 0; i < lenJ; i++ { |
| 447 | cmp, err := j[i].Compare(o[i]) |
| 448 | if err != nil { |
| 449 | return 0, err |
| 450 | } |
| 451 | if cmp != 0 { |
| 452 | return cmp, nil |
| 453 | } |
| 454 | } |
| 455 | return 0, nil |
| 456 | } |
| 457 | |
| 458 | func (j jsonObject) Compare(other JSON) (int, error) { |
| 459 | cmp := cmpJSONTypes(j.Type(), other.Type()) |
nothing calls this directly
no test coverage detected