I have two json files and I would like to get a json containing the differences. It is important that only the actual differences of
Basically, what you want is something similar to array_diff_assoc, but applied to json objects, and recursive.
The array_diff functions are not recursive because of reference issues: it is possible to assign a reference of an array to an entry of that array, making the array infinitely recursive. I don't think it is possible to get the same situation with a json object, thus making a recursive function safe.
Let's suppose that you wish to compute the difference between object A and B, and have the result in object C.
The principle is to loop over each field of A (a foreach should do), and when:
The ordering of A should be respected.