Javascript JSON Object

JavaScript Object Notation - JSON is a very lightweight data-interchange format. The most improtant thing about JSON is, easy to read and write. It is language-independent data exchange format that makes you easy to easily share information between veriety of our systems and devices, regardless of technology.

JSON is a simple text (key-value) that is completely language independent but uses conventions that are familiar to programmers of C#, Java, JavaScript and many others. These make JSON an ideal data-interchange language.

Here is an example of JSON data:

Simple JSON Object

<html>
<head>
<title>My first JSON Object Code</title>
<SCRIPT LANGUAGE="JavaScript">
var jsonData=
{
     "firstName": "Jimi",
     "lastName": "Scotts",
     "address": "12-13-283/A1"
 }
 document.write(jsonData.firstName + ' ' + jsonData.lastame);
 </SCRIPT>
 </HEAD>
<BODY>
</BODY>
</HTML>
Try Now

Array In JSON Object

<html>
<head>
<title>My first JSON Object Code</title>
<SCRIPT LANGUAGE="JavaScript">
 var jsonData={"customer":[
        {
		 "firstName": "Jimi",
		 "lastName": "Scotts",
		 "address": "12-13-283/A1"
		 },
        {
		 "firstName": "Tom",
		 "lastName": "Scotts",
		 "address": "12-13-284/A2"
		 }
]}

 document.write(jsonData.customer[0].firstName + ' ' + jsonData.customer[0].lastame);
 </SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
Try Now

Read JSON From File

<html>
<head>
<title>My first JSON Object Code</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<SCRIPT LANGUAGE="JavaScript">

$.getJSON('javascript-json.json', function(data) {
	var displayList="<ul>";
	for (var i in jsonData.customer) {
		output+="<li>" + jsonData.customer[i].firstName + " " + jsonData.customer[i].lastName + "</li>";
	}

 displayList+="</ul>";
 document.write(displayList);
 
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
Try Now

See Also

Javascript Built in String Object
Javascript Built in Number Object
Javascript Built in Math Object
Javascript Built in Date Object
Javascript Built in Arrays Object
Javascript Built in Boolean Object
Javascript Built in RegExp Object
Javascript Built in JSON Object


 
SHARE THIS IF YOU LIKE!
submit to reddit
SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.