Schema Validation for CSON
JSON Schema can be used to validate CSON documents. CoffeeScript Object Notation (CSON) is built around the same principles as JSON but based on the CoffeeScript language instead of JavaScript. It has a terser syntax making it easier to write, while maintaining a direct and clear mapping to JSON. This direct similarity makes JSON Schema a natural choice for schema validation.
JSON
[
{
"id": 2,
"name": "An ice sculpture",
"price": 12.5,
"tags": [
"cold",
"ice"
],
"dimensions": {
"length": 7,
"width": 12,
"height": 9.5
},
"warehouseLocation": {
"latitude": -78.75,
"longitude": 20.4
}
},
{
"id": 3,
"name": "A blue mouse",
"price": 25.5,
"dimensions": {
"length": 3.1,
"width": 1,
"height": 1
},
"warehouseLocation": {
"latitude": 54.4,
"longitude": -32.7
}
}
]
CSON
[
{
id: 2
name: "An ice sculpture"
price: 12.5
tags: [
"cold"
"ice"
]
dimensions:
length: 7
width: 12
height: 9.5
warehouseLocation:
latitude: -78.75
longitude: 20.4
}
{
id: 3
name: "A blue mouse"
price: 25.5
dimensions:
length: 3.1
width: 1
height: 1
warehouseLocation:
latitude: 54.4
longitude: -32.7
}
]
Editor Support
No editors supporting JSON Schema validation of CSON documents are known.
Tools and Libraries
- Polyglottal JSON Schema Validator - Written in JavaScript. Released under the MIT license.
- Polyglottal JSON Schema Validator (pajv) is a command line utility that can be used to validate data in numerous formats against a JSON Schema.
Alternatives
No other schema definition formats are known to target CSON.