Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 22, 2014 17:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save devdays/4ba2546cbdc90042b9ea to your computer and use it in GitHub Desktop.
Save devdays/4ba2546cbdc90042b9ea to your computer and use it in GitHub Desktop.
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