Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reading a JSON (Serialize) Data

Posted on 2013-01-14
4
Medium Priority
?
344 Views
Last Modified: 2013-01-14
Hi Folks,

I have the following json data

{"CTS":"0,51,52","lastTopic":53,"questions_answered":["3","2","4","1","9"],"scoreArray":[],"06_01":20}

Open in new window


How do I read scoreArray value of 20 which is the last value in Javascript

Thanks

RG
0
Comment
Question by:rgarimella
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 38776662
for example : http://jsfiddle.net/tb2MF/
var j = {
    "CTS": "0,51,52",
    "lastTopic": 53,
    "questions_answered": [
        "3",
        "2",
        "4",
        "1",
        "9"
    ],
    "scoreArray": [4,5,6,8,1,2,9,3,0,4,5,6,8,1,2,9,3,0],
    "06_01": 20
}

for(v=0;v<j.scoreArray.length;v++) {
  alert(j.scoreArray[v]);
}

Open in new window

0
 

Author Comment

by:rgarimella
ID: 38776717
Thanks, but this code does not read the value of "06_01": 20

All I need is the value stored in 06_01
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 38776727
Use : j["06_01"]
Test page : http://jsfiddle.net/tb2MF/2/
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question