jQuery Snippet - Sample Data
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
// 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