How To Create Or Get Values Of JSON Object in JavaScript Example?



JavaScript is a general purpose programming language that was introduced as the page scripting language for Netscape Navigator. JSON or JavaScript Object Notation  is a subset of the object literal notation of JavaScript. It has become a popular for defining structured data using JavaScript.

How To Create Or Get Values Of JSON Object in JavaScript Example goes below:


JSON supports following values:
number (integer or floating point)
    string
    boolean
    array
    object
    null
Here is the example for creating JSON object :
var JsonObj={
'langName' : "javascript",
'notation' : "JSON",
'price': 500,
'date': "28 July 2013",
'easy' : "true"
};

JSON attributes is accessed by using '.' (dot) Operator easily.
So if we want to access langName attribute, we can access like this:

JsonObj.langName   here JsonObj (JSON object name) and langName is object attribute.
output: javascript

Similarly for price attribute:
JsonObj.price
output: 500

Check running example here:
http://jsfiddle.net/jeetu_verma11/A7t2m/9/
Share on Google Plus

About JK STACK

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

1 comments:

  1. [...] JSON (mean how to create and what is the structure of JSON Oject ) then follow these links: 1.  http://www.jkstack.com/2013/07/how-to-create-json-object-in-javascript.html [...]

    ReplyDelete