-
-
Save deoxxa/6e7a26106e06bf540999 to your computer and use it in GitHub Desktop.
JSON Schema Example
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
{ | |
"id": 1, | |
"title": "Hello, World!", | |
"content": "This is a sample blog post.", | |
"tags": ["sample", "hello world"], | |
"comments": [ | |
{"name": "User A", "email": "user.a@example.com", "time": "Sat Jul 02 2011 12:43:21 GMT+1000 (EST)", "comment": "Great post!"}, | |
{"name": "User B", "email": "user.b@example.com", "time": "Sat Jul 02 2011 11:45:47 GMT+900 (JST)", "comment": "I agree with User A"} | |
] | |
} |
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
"blog_post": { | |
"type": ["hash"], | |
"children": { | |
"id": { | |
"type": ["numeric"] | |
}, | |
"title": { | |
"type": ["text","text_extended"], | |
"attributes": { | |
"text_extended_max_length": 120 | |
} | |
}, | |
"content": { | |
"type": ["text"] | |
}, | |
"tags": { | |
"type": ["list"], | |
"items": { | |
"type": ["text","text_extended"], | |
"attributes": { | |
"text_extended_max_length": 30 | |
} | |
} | |
}, | |
"comments": { | |
"type": ["list"], | |
"items": { | |
"type": ["hash"], | |
"children": { | |
"name": { | |
"type": ["text","text_extended"], | |
"attributes": { | |
"text_extended_max_length": 40 | |
} | |
}, | |
"email": { | |
"type": ["text","text_extended"], | |
"attributes": { | |
"text_extended_max_length": 100 | |
} | |
}, | |
"time": { | |
"type": ["text","text_timestamp"] | |
}, | |
"comment": { | |
"type": ["text","text_extended"], | |
"attributes": { | |
"text_extended_max_length": 10000 | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
1cg
commented
Sep 8, 2011
via email
100% agreement.
Thanks for your comment!
…On Thu, Sep 8, 2011 at 6:28 AM, Conrad Pankoff < ***@***.***>wrote:
Well, it depends on the intended use I suppose. The reason mine is so
verbose is to try to reduce the amount of time I have to spend
configuring/specialising client applications as much as possible
(effectively this project is a one-man show at my workplace...). It's at the
point now where I hardly ever have to modify a client application to use a
new resource, having client libraries for different languages and plugins
for different applications that implement all of my category I, II and III
types (including things like dates, times, coordinates, temperatures,
speeds, ranges, etc) so they just magically work.
As far as I understand, you're looking to provide some sort of WSDL-like
functionality as well, so keeping things simple and having clear
restrictions in place is almost definitely the way to go. I was just making
the point that schema definitions for JSON documents have their uses and can
be incredibly handy in certain situations :).
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/6e7a26106e06bf540999
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment