Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jQuery Snippet - Sample Data
// start with JSON (perhaps received using $.getJSON() )
var myJSONString = '{' +
'"products":' +
' ['+
' { "name": "Slinky", "category": "Toy", "price": 9.56 }, ' +
' { "name": "Hamburger", "category": "Grocery", "price": 2.49 }, ' +
' { "name": "Squirt Gun", "category": "Toy", "price": 8.50 }, ' +
' { "name": "Board Game 1", "category": "Game", "price": 35 }, ' +
' { "name": "Card Game 1", "category": "Game", "price": 8.50 }, ' +
' { "name": "Poker", "category": "Game", "price": 75.50 }, ' +
' { "name": "Blocks", "category": "Toy", "price": 2.5 }, ' +
' { "name": "Tricycle", "category": "Toy", "price": 95 }, ' +
' { "name": "Jacks", "category": "Toy", "price": 3.5 }, ' +
' { "name": "Lettuce", "category": "Grocery", "price": 25 } ' +
' ] ' +
', "store": "Dover Town Center" ' +
'}';
// put JSON into an object
var myData = JSON.parse(myJSONString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.