Results 1 to 5 of 5

Thread: How to setup a JavaScript Object Notation variable?

  1. #1
    Join Date
    Aug 2006
    Posts
    332

    How to setup a JavaScript Object Notation variable?

    Hi friends,
    I am recently started with the JavaScript. I have done many basic programs in JavaScript. Now I have given an assignment about the JavaScript Object Notation variable. But I don't know about the JSON (JavaScript Object Notation) variable. so please tell me how to setup a JavaScript Object Notation variable? Expecting some help soon..!!
    Do not email me asking for tech support. Any private support is billable at $50 an hour.

  2. #2
    Join Date
    Nov 2008
    Posts
    996

    Re: How to setup a JavaScript Object Notation variable?

    JavaScript Object Notation which is also known as JSON is a lightweight computer data interchange format. It is a text-based, human-readable format for representing simple data structures and associative arrays which is called as objects. For doing the serialization and transmitting structured data over a network connection the JSON format is often used. I would like to suggest you to use the latest version of Internet Explorer because many times the problem are faced with the JSON variable in the older version.

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: How to setup a JavaScript Object Notation variable?

    Nowadays the JSON is getting more popular. Many sites are sharing data using JSON in addition to RSS feeds. The reason for using the JSON instead of RSS is that when compared to the XML and RSS, JSON feeds can be loaded asynchronously much more easily. The another good features of JSON are that it stores an information in an organized, easy-to-access manner. Also JSON gives you a human-readable collection of data that you can access in a really logical manner.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: How to setup a JavaScript Object Notation variable?

    You can use the code that I have provided for storing the JSON data. I think that you should have know what exactly is the JSON. So its time to have a look on the coding :
    Code:
    var jas = { 
        "place" : "Nightalut, NC", 
        "age" : "19", 
        "sex" : "male" 
    };
    By using the above code, will create an object that you can access using the variable jas. By enclosing the variable's value in curly braces, we're indicating that the value is an object.

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: How to setup a JavaScript Object Notation variable?

    You can follow the steps for doing the setup of JavaScript Object Notation variable :
    You will have to type the coding in your javascript area. Here is an example of code :
    Code:
    var displayMessages = {
    sayHi: "hi",
    sayBye: "bye"
    };
    Now if you want to make globally accessible object references within your javascript file, you can use the following JSON :
    Code:
    var myObjects = {
    objectOne: function() {
    return document.getElementById('myNameIdHere');
    },
    objectTwo: function() {
    return document.getElementById('myNameIdHere1');
    }
    };

Similar Threads

  1. Replies: 3
    Last Post: 08-01-2011, 06:20 AM
  2. How to Pass a Javascript variable to a PHP script
    By leshaspar in forum Software Development
    Replies: 4
    Last Post: 24-11-2010, 10:48 AM
  3. Replies: 5
    Last Post: 25-01-2010, 04:59 PM
  4. Replies: 2
    Last Post: 28-08-2009, 07:51 PM
  5. javascript dynamic variable name
    By Lauren Bacall in forum Software Development
    Replies: 3
    Last Post: 17-06-2009, 04:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,710,814,570.16940 seconds with 17 queries