Duplicate key
kevinmcdonnell opened this issue · comments
Kevin McDonnell commented
This doesn't seem to identify duplicate keys, is that suppose to be covered?
Jordi Boggiano commented
It does but it's an optional feature as by default it tries to behave like json_decode() does.
Here is an example:
$jsonParser = new JsonParser;
try {
$jsonParser->parse(file_get_contents($jsonFile), JsonParser::DETECT_KEY_CONFLICTS);
} catch (DuplicateKeyException $e) {
$details = $e->getDetails();
echo 'Key '.$details['key'].' is a duplicate in '.$jsonFile.' at line '.$details['line'];
}