{"id":13623772,"url":"https://github.com/Seldaek/jsonlint","last_synced_at":"2025-04-15T20:32:15.396Z","repository":{"id":2036951,"uuid":"2973808","full_name":"Seldaek/jsonlint","owner":"Seldaek","description":"JSON Lint for PHP","archived":false,"fork":false,"pushed_at":"2024-08-28T08:46:26.000Z","size":168,"stargazers_count":1328,"open_issues_count":3,"forks_count":57,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-04-10T00:05:26.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Seldaek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Seldaek"],"tidelift":"packagist/seld/jsonlint"}},"created_at":"2011-12-13T17:07:43.000Z","updated_at":"2025-04-04T15:55:54.000Z","dependencies_parsed_at":"2024-11-06T00:02:03.522Z","dependency_job_id":"51c2e651-36db-4f12-87ca-696b6a63f0b7","html_url":"https://github.com/Seldaek/jsonlint","commit_stats":{"total_commits":146,"total_committers":41,"mean_commits":"3.5609756097560976","dds":0.452054794520548,"last_synced_commit":"ef7e0af881a30f0520cb12d8977b77d57a9f3a95"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seldaek%2Fjsonlint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seldaek%2Fjsonlint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seldaek%2Fjsonlint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seldaek%2Fjsonlint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seldaek","download_url":"https://codeload.github.com/Seldaek/jsonlint/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647301,"owners_count":21139086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:01:35.465Z","updated_at":"2025-04-15T20:32:15.136Z","avatar_url":"https://github.com/Seldaek.png","language":"PHP","funding_links":["https://github.com/sponsors/Seldaek","https://tidelift.com/funding/github/packagist/seld/jsonlint"],"categories":["杂项","Linters","杂项 Miscellaneous","目录","Table of Contents","PHP","Configuration","Miscellaneous"],"sub_categories":["JSON","Miscellaneous","Globalization"],"readme":"JSON Lint\n=========\n\n[![Build Status](https://github.com/Seldaek/jsonlint/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/Seldaek/jsonlint/actions/workflows/continuous-integration.yml)\n\nUsage\n-----\n\n```php\nuse Seld\\JsonLint\\JsonParser;\n\n$parser = new JsonParser();\n\n// returns null if it's valid json, or a ParsingException object.\n$parser-\u003elint($json);\n\n// Call getMessage() on the exception object to get\n// a well formatted error message error like this\n\n// Parse error on line 2:\n// ... \"key\": \"value\"    \"numbers\": [1, 2, 3]\n// ----------------------^\n// Expected one of: 'EOF', '}', ':', ',', ']'\n\n// Call getDetails() on the exception to get more info.\n\n// returns parsed json, like json_decode() does, but slower, throws\n// exceptions on failure.\n$parser-\u003eparse($json);\n```\n\nYou can also pass additional flags to `JsonParser::lint/parse` that tweak the functionality:\n\n- `JsonParser::DETECT_KEY_CONFLICTS` throws an exception on duplicate keys.\n- `JsonParser::ALLOW_DUPLICATE_KEYS` collects duplicate keys. e.g. if you have two `foo` keys they will end up as `foo` and `foo.2`.\n- `JsonParser::PARSE_TO_ASSOC` parses to associative arrays instead of stdClass objects.\n- `JsonParser::ALLOW_COMMENTS` parses while allowing (and ignoring) inline `//` and multiline `/* */` comments in the JSON document.\n- `JsonParser::ALLOW_DUPLICATE_KEYS_TO_ARRAY` collects duplicate keys. e.g. if you have two `foo` keys the `foo` key will become an object (or array in assoc mode) with all `foo` values accessible as an array in `$result-\u003efoo-\u003e__duplicates__` (or `$result['foo']['__duplicates__']` in assoc mode).\n\nExample:\n\n```php\n$parser = new JsonParser;\ntry {\n    $parser-\u003eparse(file_get_contents($jsonFile), JsonParser::DETECT_KEY_CONFLICTS);\n} catch (DuplicateKeyException $e) {\n    $details = $e-\u003egetDetails();\n    echo 'Key '.$details['key'].' is a duplicate in '.$jsonFile.' at line '.$details['line'];\n}\n```\n\n\u003e **Note:** This library is meant to parse JSON while providing good error messages on failure. There is no way it can be as fast as php native `json_decode()`.\n\u003e\n\u003e It is recommended to parse with `json_decode`, and when it fails parse again with seld/jsonlint to get a proper error message back to the user. See for example [how Composer uses this library](https://github.com/composer/composer/blob/56edd53046fd697d32b2fd2fbaf45af5d7951671/src/Composer/Json/JsonFile.php#L283-L318):\n\n\nInstallation\n------------\n\nFor a quick install with Composer use:\n\n```bash\ncomposer require seld/jsonlint\n```\n\nJSON Lint can easily be used within another app if you have a\n[PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md)\nautoloader, or it can be installed through [Composer](https://getcomposer.org/)\nfor use as a CLI util.\nOnce installed via Composer you can run the following command to lint a json file or URL:\n\n    $ bin/jsonlint file.json\n\nRequirements\n------------\n\n- PHP 5.3+\n- [optional] PHPUnit 3.5+ to execute the test suite (phpunit --version)\n\nSubmitting bugs and feature requests\n------------------------------------\n\nBugs and feature request are tracked on [GitHub](https://github.com/Seldaek/jsonlint/issues)\n\nAuthor\n------\n\nJordi Boggiano - \u003cj.boggiano@seld.be\u003e - \u003chttp://twitter.com/seldaek\u003e\n\nLicense\n-------\n\nJSON Lint is licensed under the MIT License - see the LICENSE file for details\n\nAcknowledgements\n----------------\n\nThis library is a port of the JavaScript [jsonlint](https://github.com/zaach/jsonlint) library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSeldaek%2Fjsonlint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSeldaek%2Fjsonlint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSeldaek%2Fjsonlint/lists"}