Json In 5 Slices.Key

691 views

Published on

Quick introduction to JSON

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
691
On SlideShare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Json In 5 Slices.Key

    1. 1. JSON in 5 slices Hendrik Van Belleghem Vlaanderen.pm
    2. 2. JSON in 5 slices Hendrik Van Belleghem Vlaanderen.pm
    3. 3. What is JSON?
    4. 4. What is JSON?
    5. 5. What is JSON? • Obviously not Perl!
    6. 6. What is JSON? • Obviously not Perl! • Poor man’s (Javascript’s) data serialization
    7. 7. What is JSON? • Obviously not Perl! • Poor man’s (Javascript’s) data serialization • Complex data structures
    8. 8. What is JSON? • Obviously not Perl! • Poor man’s (Javascript’s) data serialization • Complex data structures • Can be eval’ed
    9. 9. What is JSON? • Obviously not Perl! • Poor man’s (Javascript’s) data serialization • Complex data structures • Can be eval’ed • Human readable
    10. 10. What is JSON? • Obviously not Perl! • Poor man’s (Javascript’s) data serialization • Complex data structures • Can be eval’ed • Human readable • Hotter than Megan Fox’ pants!
    11. 11. The Plot
    12. 12. The Plot
    13. 13. The Plot var Plot = { "Location": "Crystal Lake", // Hash "Killers": [ "Mrs Voorhees", "Jason Voorhees", "Roy Burns" ], // Hash with array "Synopsis": "Guy with hockey mask kills people who visit Crystal Lake", "How To Kill": // Hash with hash ; Name contains spaces ;-) { "Mrs Voorhees": "Decapitate", "Jason Voorhees": [ "Machete", "Axe to the head", "Drowning", // Array "Dragged underwater", "Melted by toxic waste", // within "Stabbed with Mystical Dagger", "Ejected into space" // hash ], "Roy Burns": "Steel spikes" }, "Lessons Learned": "Don't have sex when you visit Crystal Lake" }
    14. 14. The Twist
    15. 15. The Twist
    16. 16. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming
    17. 17. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming
    18. 18. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming // Iterate through array for(i=0; i < Plot.Killers.length ; i++) // Who are the killers? { document.write(document.write(Plot.Killers[i]);); }
    19. 19. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming // Iterate through array for(i=0; i < Plot.Killers.length ; i++) // Who are the killers? { document.write(document.write(Plot.Killers[i]);); }
    20. 20. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming // Iterate through array for(i=0; i < Plot.Killers.length ; i++) // Who are the killers? { document.write(document.write(Plot.Killers[i]);); } // No standard naming possible, use [ “ “ ] to read how to kill Mrs Voorhees document.write(Plot["How To Kill"]["Mrs Voorhees"]);
    21. 21. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming // Iterate through array for(i=0; i < Plot.Killers.length ; i++) // Who are the killers? { document.write(document.write(Plot.Killers[i]);); } // No standard naming possible, use [ “ “ ] to read how to kill Mrs Voorhees document.write(Plot["How To Kill"]["Mrs Voorhees"]);
    22. 22. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming // Iterate through array for(i=0; i < Plot.Killers.length ; i++) // Who are the killers? { document.write(document.write(Plot.Killers[i]);); } // No standard naming possible, use [ “ “ ] to read how to kill Mrs Voorhees document.write(Plot["How To Kill"]["Mrs Voorhees"]); // Array within array.. // OMGWTFBBQ He's alive!!?! How do I kill Jason?? for(i=0; i < Plot["How To Kill"]["Jason Voorhees"].length ; i++) { document.write(Plot["How To Kill"]["Jason Voorhees"][i]); }
    23. 23. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming // Iterate through array for(i=0; i < Plot.Killers.length ; i++) // Who are the killers? { document.write(document.write(Plot.Killers[i]);); } // No standard naming possible, use [ “ “ ] to read how to kill Mrs Voorhees document.write(Plot["How To Kill"]["Mrs Voorhees"]); // Array within array.. // OMGWTFBBQ He's alive!!?! How do I kill Jason?? for(i=0; i < Plot["How To Kill"]["Jason Voorhees"].length ; i++) { document.write(Plot["How To Kill"]["Jason Voorhees"][i]); }
    24. 24. The Twist document.write(Plot.Location); // Standard naming document.write(Plot.Synopsis); // Standard naming // Iterate through array for(i=0; i < Plot.Killers.length ; i++) // Who are the killers? { document.write(document.write(Plot.Killers[i]);); } // No standard naming possible, use [ “ “ ] to read how to kill Mrs Voorhees document.write(Plot["How To Kill"]["Mrs Voorhees"]); // Array within array.. // OMGWTFBBQ He's alive!!?! How do I kill Jason?? for(i=0; i < Plot["How To Kill"]["Jason Voorhees"].length ; i++) { document.write(Plot["How To Kill"]["Jason Voorhees"][i]); } // And finally, what have we learned of this carnage? document.write(Plot.["Lessons Learned"]);
    25. 25. The End!
    26. 26. The End!
    27. 27. The End! • Square brackets are for arrays
    28. 28. The End! • Square brackets are for arrays • except when you’re using non-standard names
    29. 29. The End! • Square brackets are for arrays • except when you’re using non-standard names • Curly braces are for hash-like structures
    30. 30. The End! • Square brackets are for arrays • except when you’re using non-standard names • Curly braces are for hash-like structures • Use colons to separate names and values
    31. 31. The End! • Square brackets are for arrays • except when you’re using non-standard names • Curly braces are for hash-like structures • Use colons to separate names and values • Separate elements with a comma
    32. 32. The End! • Square brackets are for arrays • except when you’re using non-standard names • Curly braces are for hash-like structures • Use colons to separate names and values • Separate elements with a comma • Don't have sex when you visit Crystal Lake!

    ×