Header Ads

Creating Object in JavaScript using JSON


JSON stands for JavaScript Object Notation that is a language independent text format which is fast and easy to understand. That means it is really very simple and easy to learn without sparing much time. In another words we can say that JavaScript Object Notation is a lightweight data-interchange format that is completely language independent but with some conventions.

So in this section of JSON tutorial we are going to discuss JSON with JavaScript.

Creating Object in JavaScript using JSON

We can create objects in JSON with JavaScript in many ways :

1. "var JSONObjectName ={};" will create an empty object.

2. "var JSONObjectName= new Object();" will create a new Object.

3. "var JSONObjectName = { "name ":"Navaskhan", "age":23}; will create an Object with attribute name which contains value in String and age with numeric value.

Now by creating this object we can access attributes by only "." operator.

Here is the full example code for creating an Object in JavaScript using JSON:

Object creation in JSON in JavaScript
<script language="javascript" >
var JSONObject = { "name" : "Navaskhan",
"address" : "B-123 Bangalow",
"age" : 23,
"phone" : "044-4565763",
"MobileNo" : 9840633083
<font color='blue'>Name</font>::"
<font color='blue'>Address</font>::"
<font color='blue'>Age</font>::"
<font color='blue'>Phone No.</font>::"
<font color='blue'>Mobile No.</font>::"
Example of object creation in JSON in JavaScript</h3>


  1. Greetings! This is my first visit to your blog! We are a group
    of volunteers and starting a new initiative in a community
    in the same niche. Your blog provided us useful information to work
    on. You have done a extraordinary job!

    my web site; calories burnt walking


Powered by Blogger.