Last active
August 29, 2015 14:20
-
-
Save Fannon/1052577fe58b347798b7 to your computer and use it in GitHub Desktop.
JSON Schema property array notation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JSON Schema Spec | |
{ | |
properties: { | |
// Property order is not ensured! two could come before one, but you'd never know... | |
one: { | |
id: "1" // Which ID is it now? One or 1? | |
type: "string" | |
}, | |
two: { | |
type: "string" | |
} | |
}, | |
// You'd have to define a custom propertiesOrder Array and iterate over this | |
// But: What if the propertiesOrder Array does not contain all properties? | |
propertiesOrder: [ | |
"one", | |
"two" | |
] | |
} | |
// My suggestion: | |
{ | |
properties: [ | |
// Property order is ensured | |
{ | |
id: one, | |
type: "string" | |
}, | |
{ | |
id: two, | |
type: "string" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment