I am writing some php code which which will be following the oauth2.0 specification. One of the requirements they specify is that any request in which parameters are repeated results in an error. As such, I have a json which I am parsing using json_decode, and I am trying to figure out how to catch if the json repeats any parameters. The result from json_decode seems to just use the last value for the key in the case of repeated parameters, so it seems like I would need to detect them before decoding. Does anyone know how to do this without writing my own json parser?
Thanks!
The approach that I ended up using was to json_encode the json decoded version of the input string and compare it to the input string. If the two match, there were no repeats. If they don’t the json_decode saw the repeat, and removed it automatically, and hence there were repeats.