// This is the JSON data as a string,
// it's the same as JSON in a file except without the surrounding ``.
const data = `{
"movies" : [
"Superman",
"Spiderman",
"Wonder Woman",
"Batman"
],
"shows":{
"gameOfThrones": "Game of Thrones",
"friends": "Friends",
"siliconValley": "Silicon Valley"
}
}`;
// We can't use it as a string, we need to convert it into
// an object using JSON.parse.
const dataAsObject = JSON.parse(data);
/*
Here we can display parts of the data.
You need to open up the developer tools console to see the results
Uncomment each line below to see more
*/
console.group('View Data');
console.log('This is the data:', dataAsObject);
// console.log('All movies:', dataAsObject.movies);
// console.log('All shows:', dataAsObject.shows);
// console.log('Game of Thrones:', dataAsObject.shows.gameOfThrones);
// console.log('Game of Thrones bracket notation:', dataAsObject.shows["gameOfThrones"]);
console.groupEnd();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.