Open adriens opened 3 years ago
Troublecase : when the json contains tabulations
:
sample-tabs.json
file content
{"message": "json with tabulations"}
$ jsonlint /d/sample-tabs.json
Error: Parse error on line 1:
{"message": "json with tabulatio
------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
at Object.parseError (C:\Users\rsoutrat\AppData\Roaming\npm\node_modules\jsonlint\lib\jsonlint.js:55:11)
at Object.parse (C:\Users\rsoutrat\AppData\Roaming\npm\node_modules\jsonlint\lib\jsonlint.js:132:22)
at parse (C:\Users\rsoutrat\AppData\Roaming\npm\node_modules\jsonlint\lib\cli.js:82:14)
at main (C:\Users\rsoutrat\AppData\Roaming\npm\node_modules\jsonlint\lib\cli.js:135:14)
at Object.<anonymous> (C:\Users\rsoutrat\AppData\Roaming\npm\node_modules\jsonlint\lib\cli.js:179:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
While with spaces.json
:
{"message": "json with spaces"}
jsonlint -p spaces.json
gives :
{
"message": "json with spaces"
}
Especially talk about the validate option : -V, --validate a JSON schema to use for validation
@HakumenNC @mbarre , vous pouvez dropper ici des fichiers pourris et des bons 🙏 ...avec rien de pas secure
first wave : jsonlint.zip
👏 Excellent, du neuf très bientot
Example with json schema validation :
Good format
$ jsonlint valid.json -V data.schema.json
{
"uuid": "2a86652f-be53-4be9-9ae6-414b3c78537f",
"name": "Jean",
"firstName": "Doe",
"hobbies": [
{
"uuid": "9f5e468a-aa72-4cd0-937d-a0845bd053e4",
"name": "coding"
},
{
"uuid": "60a7c607-7819-4679-b325-f59233154db8",
"name": "design"
},
{
"uuid": "9f5e468a-aa72-4cd0-937d-a0845bd053e4",
"name": "kayak"
}
]
}
Wrong format
$ jsonlint wrong-schema-format.json -V data.schema.json
Validation Errors:
Instance is not a required type
uri: urn:uuid:88abd13c-53f7-4d67-95ea-24e08377ce3d#/name
schemaUri: urn:uuid:5ac07cfe-8ce4-4f4c-90a6-2a8c9befb4c0#/properties/name
attribute: type
details: ["string"]
@HakumenNC tu peux dropper ça enissues direct sur la repo du hall of shame ?
Requirements
DevOPS Tools
Json linting with "JSON Lint"
Optional
https://www.npmjs.com/package/jsonlint