Skip to content

Difference ignoring order of elements in an array. #33

Closed
@webpunk

Description

@webpunk

Hi,

is there a way to get the difference between two JSON objects while ignoring the order of elements in an array. For instance, the following example currently returns 4 differences but should return 0.

$diff = new \Swaggest\JsonDiff\JsonDiff( json_decode('{"data": [{"A": 1},{"B": 2}]}'), json_decode('{"data": [{"B": 2},{"A": 1}]}'), \Swaggest\JsonDiff\JsonDiff::REARRANGE_ARRAYS ); echo "\n" . $diff->getDiffCnt() . "\n";

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions