-
-
Save johnpbloch/1642531 to your computer and use it in GitHub Desktop.
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
// Define a JSON data-structure that will look and perform like the real deal | |
// What is common to every post? Lets examine the details: | |
var forumData = { // Defining the object structure | |
"Posts" : [ // array of Posts | |
// single post item in the array | |
{ | |
// definition of properties | |
"id" : "1", | |
"user" : "Melvin", | |
"title" : "Yes, I beleive you have my stapler...", | |
"body" : "I have an orange swingline stapler, and I do beleive that you took it from me. And I'd like to have it back, thank you.", | |
"date" : "01/01/2012 4:40pm", | |
// an array of Reply Posts -- child of the parent post -- this is how we negate the ID mapping from the database, and re-mapping in the JSON object | |
// just have the server-side script parse all that from the get-go | |
"Replies" : [ | |
// first child of the Reply Array -- since this is an array of objects, it has to be encased in {} -- a sequence would be {},{} | |
{ | |
"id" : "127", | |
"user" : "Lumburgh", | |
"title" : null, | |
"body" : "Yeah... About that - We're gonna need you to move down to B1. So if you could just clean out your desk and take all your things down that would be great...mkay? yeah....", | |
"date" : "01/01/2012 4:41pm" | |
},// <-- notice the comma, delimiting there is another item in the sequence. | |
// second child of the Reply Array | |
{ | |
"id" : "128", | |
"user" : "Peter", | |
"title" : null, | |
"body" : "Yeah, I'm really busy Lumburgh... I'm going to have to ask you to come back later. I've got a meeting with the bobs in a few minutes.", | |
"date" : "01/01/2012 5:00pm" | |
} // <-- this one does not have a comma -- this denotes its the end of the sequence | |
] // <-- this denotes the end of the array | |
},// end of the first post object | |
{ | |
// definition of properties | |
"id" : "2", | |
"user" : "LazyPower", | |
"title" : "UnderWater Basket Weaving?!", | |
"body" : "I'm looking to learn Underwater Basket Weaving. Does anyone have any suggestions on where I could start?", | |
"date" : "01/01/2012 3:00pm", | |
// an array of Reply Posts -- child of the parent post -- this is how we negate the ID's in the JSON object | |
"Replies" : [ | |
// first child of the Reply Array | |
{ | |
"id" : "228", | |
"user" : "John McKitty", | |
"title" : null, | |
"body" : "You could always sign up for classes at ITT Tech. I heard they have a great Under-Water Basket Weaving class, my cousin graduated with honors!", | |
"date" : "01/01/2012 4:45pm" | |
} | |
] // end of the reply array | |
}, | |
{ | |
"id" : "3", | |
"user" : "Noob", | |
"title" : "Best FLASHPOINT EVARRRR!!!!", | |
"body" : "Who knows the best flashpoint in SWTOR?!", | |
"date" : "01/01/2012 2:00am" | |
} | |
] // end of the posts Object | |
} // end of the Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment