Login   Register  
Icontem

File: example.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Daniel Martinez  >  Converter Array To JSON  >  example.html  >  Download  
File: example.html
Role: Example script
Content type: text/plain
Description: example of use converterArrayToJson class
Class: Converter Array To JSON
Convert arrays or objects into JSON strings
Author: By
Last change: Clarification
Date: 2011-03-13 08:12
Size: 1,795 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="autor" content="Daniel Martínez Castillo"/>
<title>converterArrayToJson example</title>
<script type="text/javascript" src="converterArrayToJson.class.js"></script>
<script type="text/javascript">
		myArray = new Array();
		myArray["one"] = "This";
		myArray["two"] = "is";
		myArray[3] = "an example";
		myArray[4] = "of mixed array";
		myArray["five"] = {
			fiveVar : "foo",
			fiveVar2: 700
		};
		var myVar = new converterArrayToJson(myArray);
</script>
</head>
<body>

<h4>This is an example of converterArrayToJson class.</h4>
<p>
	You can contact me at <a href="mailto:danimartcas@hotmail.com">danimartcas@hotmail.com</a>
</p>
<br />
<h4>Thank you for download it!</h4>


<h3>An mixed array :</h3>
<pre>
myArray = new Array();
		myArray["one"] = "This";
		myArray["two"] = "is";
		myArray[3] = "an example";
		myArray[4] = "of mixed array";
		myArray["five"] = {
			fiveVar : "foo",
			fiveVar2: 700
		};
</pre>
<h4>Outputs: </h4>
<p> 
<pre>
   {
    "one": "This",
    "two": "is",
    "3": "an example",
    "4": "of mixed array",
    "five": [
        {
            "fiveVar": "foo",
            "fiveVar2": 700
        }
    		]
    }
</pre>
	<script type="text/javascript">
		document.write(myVar.getJson());
	</script>
</p>

<!-- Output
   {
    "one": "This",
    "two": "is",
    "3": "an example",
    "4": "of mixed array",
    "five": [
        {
            "fiveVar": "foo",
            "fiveVar2": 700
        }
    ]
}-->
</body>
</html>