Seldaek / jsonlint

JSON Lint for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate key

kevinmcdonnell opened this issue · comments

This doesn't seem to identify duplicate keys, is that suppose to be covered?

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'];
            }