在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Seldaek/jsonlint开源软件地址:https://github.com/Seldaek/jsonlint开源编程语言:PHP 100.0%开源软件介绍:JSON LintUsageuse Seld\JsonLint\JsonParser;
$parser = new JsonParser();
// returns null if it's valid json, or a ParsingException object.
$parser->lint($json);
// Call getMessage() on the exception object to get
// a well formatted error message error like this
// Parse error on line 2:
// ... "key": "value" "numbers": [1, 2, 3]
// ----------------------^
// Expected one of: 'EOF', '}', ':', ',', ']'
// Call getDetails() on the exception to get more info.
// returns parsed json, like json_decode() does, but slower, throws
// exceptions on failure.
$parser->parse($json); You can also pass additional flags to
Example: $parser = new JsonParser;
try {
$parser->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'];
}
InstallationFor a quick install with Composer use:
JSON Lint can easily be used within another app if you have a PSR-4 autoloader, or it can be installed through Composer for use as a CLI util. Once installed via Composer you can run the following command to lint a json file or URL:
Requirements
Submitting bugs and feature requestsBugs and feature request are tracked on GitHub AuthorJordi Boggiano - [email protected] - http://twitter.com/seldaek LicenseJSON Lint is licensed under the MIT License - see the LICENSE file for details AcknowledgementsThis library is a port of the JavaScript jsonlint library. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论