topical media & game development

talk show tell print

mashup-amazon-12-12-01-Helloworld-HelloJSONWorld.htm / htm



  <html>
  <head>
  <script language="javascript">
  
  var myJSON = {"MyObject" : { "name" : "HelloWorld" } } ;
  var myAlbum = { "Album": { "Title": "Are You Experienced?", "Artist" : "The Jimi Hendrix Experience", "Songs" : [ "Hear My Train a Coming", "Red House", "Manic Depression" ] } } ;
  
  function ShowAlbum( strObj ) {
    document.getElementById('myResults').innerHTML = strObj.Album.Songs[2];
  }
  
  function HelloJSONWorld( strObj ) {
    document.getElementById('myResults').innerHTML = strObj.MyObject.name;
  }
  
  </script>
      <link href="styles.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
      <div class="siteHeading">Dynamic Script Example</div>
      <div class="mainTable">
          This example provides two examples of the JSON notation. <br/>
          <b>Example A: </b>{"MyObject" : { "name" : "HelloWorld" } }<br/>
          Click to show <a href="javascript:void(0)" id="myTrigger" onclick="javascript:HelloJSONWorld(myJSON)">strObj.MyObject.name;</a><br/><br/>
          <br/>
          <b>Example B:</b> { "Album": { "Title": "Are You Experienced?", "Artist" : "The Jimi Hendrix Experience", "Songs" : [ "Hear My Train a Coming", "Red House", "Manic Depression" ] } } <br/>
          Click to show <a href="javascript:void(0)" id="myTrigger" onclick="javascript:ShowAlbum(myAlbum)">strObj.Album.Songs[2];</a><br/>
          <br/>
          <b><div id="myResults">Click an example to display the results. </div></b>
      </div>
  </body>
  </html>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.