-
Notifications
You must be signed in to change notification settings - Fork 19
JSON_Schema_experiment
Adrian Holovaty edited this page Feb 16, 2023
·
2 revisions
Here's a light first stab at a formal JSON Schema for JSON MNX. The goal is really to get a feel for JSON Schema and see whether it will work for our project.
See json-schema.org for more on JSON Schema.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://w3c.github.io/mnx/schema.json",
"title": "MNX document",
"description": "An encoding of Common Western Music Notation.",
"type": "object",
"properties": {
"global": {
"type": "object",
"properties": {
"measures": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "object",
"properties": {
"fifths": {
"type": "integer"
}
},
"required": ["fifths"]
},
"time": {
"type": "object",
"properties": {
"signature": {
"type": "string"
}
},
"required": ["signature"]
}
}
}
},
"styles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"selector": {
"type": "string"
},
"color": {
"type": "string"
}
},
"required": ["selector"]
}
}
},
"required": ["measures"]
},
"parts": {
"type": "object",
"patternProperties": {
"^[a-z0-9_-]+$": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"measures": {
"type": "array",
"items": {
"type": "object",
"properties": {
"content": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"pattern": "^clef$"
},
"sign": {
"type": "string"
},
"line": {
"type": "integer"
}
},
"required": ["type", "sign", "line"]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"pattern": "^sequence$"
},
"content": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"pattern": "^event$"
},
"value": {
"type": "string"
},
"notes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"pitch": {
"type": "string"
},
"accidental": {
"type": "string"
}
},
"required": ["pitch"]
}
}
},
"required": ["type", "value"]
}
]
}
}
},
"required": ["type", "content"]
}
]
}
}
}
}
}
}
}
}
},
"scores": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"layout": {
"type": "string"
},
"multimeasure-rests": {
"type": "array",
"items": {
"type": "object",
"properties": {
"start": {
"type": "integer"
},
"duration": {
"type": "integer"
}
},
"required": ["start", "duration"]
}
}
},
"required": ["name"]
}
}
},
"required": ["global", "parts"]
}