JsonMachine\Exception\InvalidArgumentException: JSON Pointers must not intersect. At least these two do: '/page_size', '/page'
Possible Cause
While validating, the pointers are all compared to each other. One way in which they are compared is by checking if one contains the other, in which case they are considered intersecting. However, while the string /page_size contains /page, they are in fact separate keys, and do not intersect.
Suggested Solution
Add a path delimiter to the end of each compared pointer string. This will ensure that the pointers explicitly terminate.
Symptoms
Let's say I have some sample data:
I want the values of
page
andpage_size
keys, so I read this into a streaming collection:I get an error:
Possible Cause
While validating, the pointers are all compared to each other. One way in which they are compared is by checking if one contains the other, in which case they are considered intersecting. However, while the string
/page_size
contains/page
, they are in fact separate keys, and do not intersect.Suggested Solution
Add a path delimiter to the end of each compared pointer string. This will ensure that the pointers explicitly terminate.
Comparing two terminated pointers in this way would mean comparing
/page/
and/page_size/
in this case:/page_size/
does not contain/page/
. This is a similar approach to why Composer requires autoload namespace declarations to terminate with a namespace delimiter.