Reading:  

Getting start with JSON


Working with Objects

JSON objects can be created using Javascript. Below is the example for creating it.

 

var JSONObj = {};

 

The JSON object can be created using new Keyword in Javascript.

 

var JSONObj = new Object();

 

The below example shows the creation of object with attribute name and value. The attribute is accessed using ‘.’ Operator.

 

var JSONObj = { "firstname":"Nimrit", "lastname":"Chahal" };


Here is an example HTML file illustrating JSON objects use

<html>
<head>
<title>Creating Object JSON with JavaScript</title>
<script language="javascript" >

  var JSONObj = { "firstname":"Nimrit", "lastname":"Chahal"  };
  document.write("<h1>JSON JavaScript Example</h1>");
  document.write("<br>");
  document.write("<h3>First Name="+JSONObj.firstname+"</h3>");  
  document.write("<h3>Last Name="+JSONObj.lastname+"</h3>");  

</script>
</head>
<body>
</body>
</html>
 

 

You will see something like this in your browser

Example JSON objects

 

Description

In this tutorial you will learn 

  1. What is JSON
  2. Syntax
  3. Datatypes with JSON
  4. Objects
  5. Schema
  6. XML vs JSON
  7. Using with PHP and Java

This tutorial is a quick walkthrough over the technology

 



Learning Objectives

Objective of this tutorial is to give you enough information on JSON to get you started with the technology

Author: Subject Coach
Added on: 20th Jul 2015

You must be logged in as Student to ask a Question.

None just yet!