SlideShare a Scribd company logo
1 of 27
JSON
fat-free, independent & self-describing




                   1                 Karel Persoons
Introductie
  • JSON = JavaScript Object Notation
  • Data in tekstvorm
  • Subset van Javascript
  • Gebaseerd op object-structuur


JSON                 2              Karel Persoons
Kenmerken

  • Fat-free: compact (ivm XML)
  • Independent: open systeem
  • Self-describing: gemakkelijk te lezen
       en te schrijven




JSON                     3            Karel Persoons
Notatie

  • Begint met ‘{’ en eindigt met ‘}’
  • Daarin collectie van namen + waarden
  • Gescheiden met ‘:’ en herhalen via ‘,’



JSON                    4               Karel Persoons
Notatie
  {
       “voornaam”: “Karel”,
       “naam”: “Persoons”,
       “leeftijd”: 26,
       “adres”: {”stad”: “Brugge”, ...},
       “talen”: [”nl”, “en”, ...],
       “getrouwd”: false,
       “kinderen”: null
  }




JSON                    5                  Karel Persoons
String
  “voornaam”: “Karel”,



  • Tekst tussen dubbele
       aanhalingstekens

  • Speciale -escapement


JSON                      6   Karel Persoons
Integer
  “leeftijd”: 26,



  • Getallen
  • Decimalen via ‘.’
  • Geen bewerkingen


JSON                    7   Karel Persoons
Object
  “adres”: {”stad”: “Brugge”, ...},




  • Dezelfde eigenschappen als JSON zelf
  • Leesbaarheid



JSON                  8               Karel Persoons
Array
  “talen”: [”nl”, “en”, ...],




  • Herhaling, reeks, lijst, ...
  • Leesbaarheid



JSON                     9         Karel Persoons
Object vs. Array

   verwijzing naar             verwijzing naar
   waarde moet een            waarde moet er niet
     ‘string’ zijn              expliciet zijn
                              (maar kan wel via index)

       data.adres.stad            data.talen[0]



JSON                     10                     Karel Persoons
Boolean
  “getrouwd”: false



  • ‘true’ of ‘false’
  • Zonder dubbele aanhalingstekens
  • Zeer performant


JSON                    11            Karel Persoons
Null
  “kinderen”: null




  • Geen waarde
  • Zonder dubbele aanhalingstekens



JSON                  12              Karel Persoons
Toepassingen

  • API (Facebook, Google, ...)
  • AJAX-request naar eigen server
  • Configuratie



JSON                  13             Karel Persoons
Voorbeeld

    In de volgende voorbeeld applicatie
   wordt een lijst van alle (8645) winnaars
     ingeladen via een bestand (AJAX-
                   request)




JSON                  14               Karel Persoons
Via XML
  <?xml version="1.0" encoding="utf-8"?>
  <WINNAARS>
     <WNR>
         <NM>Jansen</NM>
         <VNM>Jan</VNM>
         <WPL>Lokeren</WPL>
     </WNR>
     ...
  </WINNAARS>




JSON                  15               Karel Persoons
Via JSON
  {
       “WINNAARS”: [
          {
              “NM”: “Jansen”,
              “VNM”: “Jan”,
              “WPL”: “Lokeren”
          },
          ...
       ]
  }



JSON                     16      Karel Persoons
Bestandsgrootte
                     XML     JSON
        1.000 KB


         750 KB


         500 KB    560 KB
                             420 KB
         250 KB


           0 KB




JSON                    17            Karel Persoons
Laadtijd
                    XML*          JSON
       4s


       3s         3,3 s


       2s


       1s


       0s                         0,2 s

            * XML wordt omgezet naar object



JSON                      18                  Karel Persoons
Code jQuery
  $.ajax({
      type: ‘GET’,
      url: ‘winnaars.json’,
      dataType: ‘json’,
      success: function(data){
         $.each(data, function(index, value){
             // loop data here
         });
      }
  });



JSON                   19               Karel Persoons
Meer info

  • $.ajax()
  • $.getJSON() (shortcut)




JSON                 20      Karel Persoons
Opmerking

  • Indien tekst: JSON.parse()
  • Voor oudere browers: JSON2.js
  • Gebruik ‘console.log’!



JSON                  21            Karel Persoons
Voordelen
  • Licht
  • Gebruiksvriendelijk
  • Stabiel (toekomstgericht)
  • Eén versie


JSON                 22         Karel Persoons
Nadelen
  • Geen comments
  • Geen validatie
  • Mist voordelen van XML (stylesheets,
       strict, industriestandaard, ...)

  • Eén versie


JSON                      23              Karel Persoons
Handige tools
  • XML to JSON
  • JSON validator
  • JSON editor / viewer
  • JSON report
  • Firebug of Developer Tools

JSON                 24          Karel Persoons
Links

  • JSON
  • JSON - Wikipedia




JSON                   25   Karel Persoons
Vragen

  • Don’t panic, just ask!
  • Mailen naar karel@studiosmeeuw.be
  • Stack Overflow (JSON)



JSON                  26          Karel Persoons
JSON
fat-free, independent & self-describing

             Karel Persoons
       in opdracht voor Corelio NV
                  2012


                   27                Karel Persoons

More Related Content

Featured

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

JSON - fat-free, independent & self-describing

  • 1. JSON fat-free, independent & self-describing 1 Karel Persoons
  • 2. Introductie • JSON = JavaScript Object Notation • Data in tekstvorm • Subset van Javascript • Gebaseerd op object-structuur JSON 2 Karel Persoons
  • 3. Kenmerken • Fat-free: compact (ivm XML) • Independent: open systeem • Self-describing: gemakkelijk te lezen en te schrijven JSON 3 Karel Persoons
  • 4. Notatie • Begint met ‘{’ en eindigt met ‘}’ • Daarin collectie van namen + waarden • Gescheiden met ‘:’ en herhalen via ‘,’ JSON 4 Karel Persoons
  • 5. Notatie { “voornaam”: “Karel”, “naam”: “Persoons”, “leeftijd”: 26, “adres”: {”stad”: “Brugge”, ...}, “talen”: [”nl”, “en”, ...], “getrouwd”: false, “kinderen”: null } JSON 5 Karel Persoons
  • 6. String “voornaam”: “Karel”, • Tekst tussen dubbele aanhalingstekens • Speciale -escapement JSON 6 Karel Persoons
  • 7. Integer “leeftijd”: 26, • Getallen • Decimalen via ‘.’ • Geen bewerkingen JSON 7 Karel Persoons
  • 8. Object “adres”: {”stad”: “Brugge”, ...}, • Dezelfde eigenschappen als JSON zelf • Leesbaarheid JSON 8 Karel Persoons
  • 9. Array “talen”: [”nl”, “en”, ...], • Herhaling, reeks, lijst, ... • Leesbaarheid JSON 9 Karel Persoons
  • 10. Object vs. Array verwijzing naar verwijzing naar waarde moet een waarde moet er niet ‘string’ zijn expliciet zijn (maar kan wel via index) data.adres.stad data.talen[0] JSON 10 Karel Persoons
  • 11. Boolean “getrouwd”: false • ‘true’ of ‘false’ • Zonder dubbele aanhalingstekens • Zeer performant JSON 11 Karel Persoons
  • 12. Null “kinderen”: null • Geen waarde • Zonder dubbele aanhalingstekens JSON 12 Karel Persoons
  • 13. Toepassingen • API (Facebook, Google, ...) • AJAX-request naar eigen server • Configuratie JSON 13 Karel Persoons
  • 14. Voorbeeld In de volgende voorbeeld applicatie wordt een lijst van alle (8645) winnaars ingeladen via een bestand (AJAX- request) JSON 14 Karel Persoons
  • 15. Via XML <?xml version="1.0" encoding="utf-8"?> <WINNAARS> <WNR> <NM>Jansen</NM> <VNM>Jan</VNM> <WPL>Lokeren</WPL> </WNR> ... </WINNAARS> JSON 15 Karel Persoons
  • 16. Via JSON { “WINNAARS”: [ { “NM”: “Jansen”, “VNM”: “Jan”, “WPL”: “Lokeren” }, ... ] } JSON 16 Karel Persoons
  • 17. Bestandsgrootte XML JSON 1.000 KB 750 KB 500 KB 560 KB 420 KB 250 KB 0 KB JSON 17 Karel Persoons
  • 18. Laadtijd XML* JSON 4s 3s 3,3 s 2s 1s 0s 0,2 s * XML wordt omgezet naar object JSON 18 Karel Persoons
  • 19. Code jQuery $.ajax({ type: ‘GET’, url: ‘winnaars.json’, dataType: ‘json’, success: function(data){ $.each(data, function(index, value){ // loop data here }); } }); JSON 19 Karel Persoons
  • 20. Meer info • $.ajax() • $.getJSON() (shortcut) JSON 20 Karel Persoons
  • 21. Opmerking • Indien tekst: JSON.parse() • Voor oudere browers: JSON2.js • Gebruik ‘console.log’! JSON 21 Karel Persoons
  • 22. Voordelen • Licht • Gebruiksvriendelijk • Stabiel (toekomstgericht) • Eén versie JSON 22 Karel Persoons
  • 23. Nadelen • Geen comments • Geen validatie • Mist voordelen van XML (stylesheets, strict, industriestandaard, ...) • Eén versie JSON 23 Karel Persoons
  • 24. Handige tools • XML to JSON • JSON validator • JSON editor / viewer • JSON report • Firebug of Developer Tools JSON 24 Karel Persoons
  • 25. Links • JSON • JSON - Wikipedia JSON 25 Karel Persoons
  • 26. Vragen • Don’t panic, just ask! • Mailen naar karel@studiosmeeuw.be • Stack Overflow (JSON) JSON 26 Karel Persoons
  • 27. JSON fat-free, independent & self-describing Karel Persoons in opdracht voor Corelio NV 2012 27 Karel Persoons

Editor's Notes

  1. \n
  2. In tegenstelling tot databases, excell-bestanden, ...\n
  3. Javascript, ActionScript, C++, C#, Python, PHP\n
  4. \n
  5. Laatste combinatie heeft geen comma\n
  6. \n
  7. \n
  8. Toon voorbeeld leesbaarheid (dropgame)\n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. XML versie durft crashen in IE\n
  19. Voorbeeld later doormailen\n
  20. \n
  21. \n
  22. \n
  23. \n
  24. Ingewikkelde XML omzetten vereist kennis\nToon sites\n
  25. \n
  26. \n
  27. \n