SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question doubt regarding JSON object

    I have a JSON object as below:

    var a = {
    "Test.Attr1" : "Hi",
    "Test.Attr2" : "Hello"
    };

    How can I get the value of Test.Attr1 key's value?

  2. #2
    SitePoint Enthusiast Grayson's Avatar
    Join Date
    Jun 2008
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can JSON in js use newlines, or is it only the JSON string type? Lets say your JSON string is...

    Code javascript:
    var jsonString = '({"Test.attr1":"Hi","attr2":"Hello"})';
    var jsonObj = eval( jsonString );
    alert( jsonObj['Test.attr1'] );

    hopefully this helps
    Last edited by Grayson; Jun 28, 2008 at 02:32.

  3. #3
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, we can use new lines...

    I got solution for this, we can get value of Test.Attr1 using

    alert(a["Test.Attr1"]);


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
  •