Home Tutorialhelp Comment Minute correction to make the above code work

 
 

Comment

Omi
Minute correction to make the above code work,
June 16, 2009 at 10:36 PM

<html>
<head>
<title>
Array JSON-JavaScript Example
</title>
<script language="javascript" >

var students = { "Maths" : [
{"Name" : "Amit", // First element
"Marks" : 67,
"age" : 23 },
{
"Name" : "Sandeep", // Second element
"Marks" : 65,
"age" : 21 }
],
"Science" : [
{
"Name" : "Shaili", // First Element
"Marks" : 56,
"age" : 27 },
{
"Name" : "Santosh", // Second Element
"Marks" : 78,
"age" : 41 }
]
};
// Printing all array values
var i=0;
document.writeln("<table border='1'><tr>");
for(i=0;i<students.Maths.length;i++)
{
document.writeln("<td>");
document.writeln("<table border='0' width=100 >");
document.writeln("<tr><td><B>Name</B></td><td width=50>"
+students.Maths[i].Name+"</td></tr>");
document.writeln("<tr><td><B>Marks</B></td><td width=50>"
+students.Maths[i].Marks +"</td></tr>");
document.writeln("<tr><td><B>Age</B></td><td width=50>"
+students.Maths[i].age +"</td></tr>");
document.writeln("</table>");
document.writeln("</td>");
}
for(i=0;i<students.Science.length;i++)
{
document.writeln("<td>");
document.writeln("<table border='0' width=100 >");
document.writeln("<tr><td><B>Name</B></td><td width=50>"
+students.Science[i].Name+"</td></tr>");
document.writeln("<tr><td><B>Marks</B></td><td width=50>"
+students.Science[i].Marks +"</td></tr>");
document.writeln("<tr><td><B>Age</B></td><td width=50>"
+students.Science[i].age +"</td></tr>");
document.writeln("</table>");
document.writeln("</td>");
}
document.writeln("</tr></table>");
</script>
</head>
<body>
Using Array of objects via JSON in JavaScript
</body>
</html>
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Magazine Questions

JSON
it using JSON   The given code parse the message in JSON in JavaScript. You can parse the message with JSON in JavaScript by using the method..., visit the following link: http://www.roseindia.net/tutorials/json/creating 

Ajax Questions

json
Tutorials JSON Tutorials... data is transferred and how it is encoded. While JSON is a tool used for describing values and objects by encode the content in a very specific manner. 2)JSON 

JSON

What is JSON?
, JSON parser is used to make JSON work with other languages... Engineer" } Read more tutorials about JSON. Which programming language supports... can check the complete list at http://json.org/ Read more tutorials about JSON 

Ajax Questions

json
json  how connect ajax with json 

JavaScript Questions

json
json  how to get data in json object from database 

JavaScript Questions

Siverlight JSON
Siverlight JSON  how to use JSON in silverlight, i need to populate dynamic data by using JSON CAN ANY HELP ME   Hi Friend, Please go through the following link: http://www.roseindia.net/tutorials/json/ Thanks 

JavaScript Questions

retrieve JSON array objects in javascript
the following links: http://www.roseindia.net/tutorials/json/ArrayObject-json.shtml http://www.roseindia.net/tutorials/json/json-javascriptObject.shtml http://www.roseindia.net/tutorials/json/json-javascriptObject.shtml http://www.roseindia.net 

Mobile Applications Questions

json
json   how to develop iphone web service application using json. Please help me by giving any link where I could find an example or any help will be anticipated 

Java Beginners

JEE 7 JSON java.lang.NoClassDefFoundError: javax/json/Json
JEE 7 JSON java.lang.NoClassDefFoundError: javax/json/Json  Hi, While using the JSON in jee 7 based application I getting following errors...(Thread.java:724) Caused by: java.lang.NoClassDefFoundError: javax/json/Json 

JSON

JSON Tutorials
JSON Tutorials     ... tutorials: What is JSON? - Understand What... In the previous section of JSON tutorials you  have seen how JSON can be used 

JSON

Creating Message in JSON with JavaScript
Creating Message in JSON with JavaScript... about the JSON in JavaScript's some basic concepts of creating a simple object... a message with JSON in JavaScript. In this example of creating message in JSON 

Ajax

JSON-RPC
JSON-RPC       JSON-RPC-Java is a dynamic JSON-RPC implementation in Java. It allows you to transparently call server-side Java code from JavaScript with an included lightweight JSON-RPC 

J2EE

JEE7 JSON: How to use JEE 7 JSON API?
JEE7 JSON: How to use JEE 7 JSON API? In this tutorial I will explain you how you can use JEE 7 JSON API in your program for consuming and generating the JSON data on fly. The JSON stands for JavaScript Object Notation. The JSON 

Ajax Questions

jQuery ajax json
jQuery ajax json  Hi, How to use jQuery to load json data through Ajax request? Thanks   Hi, In Java you can use the following code to crate the json response: JSONObject obj=new JSONObject(); obj.put("name","foo 

Java Beginners

JSon Tutorial
JSon Tutorial  What is JSon? Where i can find the JSon tutorial? Thanks!   JSon Tutorial 

Java Beginners

How to sort json object?
How to sort json object?  I've been looking for a while and want a way to sort a JSON object like this: {"results": [ { "layerId": 5...", }, "geometryType": "esriGeometryPoint", } ]} I can't find any code 

JSON

JSON-JSP example
string value of that array object's index. Here is the example code of JSON...:   Download JSON-JSP Project code  ... JSON-JSP example      

Development process Questions

JSON with Java
JSON with Java  How to request Json From URI and to parse and to store the values in Java array 

JavaScript Questions

JSON array objects retrieval in javascript
("application/json"); response.getWriter().write(jsonObj.toString()); want to get above...JSON array objects retrieval in javascript   I am fetching some data... box is not populating any value, perhaps i am doing something wrong in json 

JSON

JSON in JavaScript
JSON in JavaScript       JSON stands for JavaScript Object Notation that ... conventions.  So in this section of JSON tutorial we are going to discuss 

PHP Questions

How to Make HTTP Requests Using Curl and Decoding JSON Responses in PHP
How to Make HTTP Requests Using Curl and Decoding JSON Responses in PHP  Make HTTP Requests Using Curl and Decoding JSON Responses in PHP   ... to make request to other server like payment gateways integration, fetching catalog 

Java Beginners

json and android
json and android  how can i use a json string [{"Id":10,"News":"sportnews"}] and fill a spinner for a android app?. i tried and i got a: AndroidRuntime:android.widget.ArrayAdapter.createViewFromResource(Adapter 

Ajax Questions

Ajax json
Ajax json  Hi, How consume json file in ajax program? Thanks 

JSON

JSON and Servlet example
-logging.jar, ezmorph.jar and json-lib-2.2.2-jdk15.jar.  Here is the example code.... Output: Download JSON-Servlet Project code  ... JSON and Servlet example    

Java Beginners

A better Java JSON library?
A better Java JSON library?   A better Java JSON library 

JSON

Parsing a message in JavaScript with JSON
Parsing a message in JavaScript with JSON... we have studied how to create message in JSON in JavaScript and now we will come to know that how we can parse the message in JSON in JavaScript. We can 

Mobile Applications Questions

what is json in iphone sdk
what is json in iphone sdk  What is json in iphone sdk? Is this a library and when i need to include JSon in my iPhone SDK App 

JavaScript Questions

JSON main question
JSON main question  What is the main purpose of JSON ,in which cases can i use 

Ajax Questions

JSON main question
JSON main question  What is the main purpose of JSON ,in which cases can i use 

Java Beginners

Jee 7 JSON error java.lang.ClassNotFoundException: org.glassfish.json.JsonProviderImpl
Jee 7 JSON error java.lang.ClassNotFoundException: org.glassfish.json.JsonProviderImpl  Hi, While creating jee 7 json based application I am getting... more JEE tutorials. Thanks   HI, Check more JEE tutorials. Thanks 

IDE Questions

Minute to Win It
Minute to Win It   Frnds i urgently need the code for an online game similar to cows and bulls played by two opponents. The game can be played... number may not begin with 0. Any number can be guessed in less than one minute 

JSON

Creating Array Objects in JavaScript with JSON
Creating Array Objects in JavaScript with JSON... of JavaScript-JSON tutorial you have known that how to create an object and now... in JavaScript-JSON. In our example file we have created an object "students" 

JavaScript Questions

accessing data from a json file writing javascript or using jQuery
page is built from this json file, but I can't figure out how to code... in json writing javascript. Here is some code: var novdata= { 'categories':[ {N...accessing data from a json file writing javascript or using jQuery  I 

JSON

JSONObject example in Java
;    In the previous section of JSON tutorials you  have seen how JSON can be used with JavaScript to create objects and arrays, you have also studied how to parse and create messages with JSON in JavaScript 

Java Beginners

Difference between jsonstring and json object
Difference between jsonstring and json object  Is There any difference between JsonString and jsonobjectA? if there is any differece could any one explain with example. Thanks venkatesh 

JSP Servlet Questions

Getting Json data from servlet to javascript variable
Getting Json data from servlet to javascript variable  How do i get json data from my servlet on to a variable in javascript n bind the data to display onto sigma grid.Has anyone Idea how to do 

Java Beginners

how to create this structure in json using grails
how to create this structure in json using grails  { "query": { "type": "cluster", "view": "accountActivity", "regions": [2342,334,241,13], "companies": [43228583,433421683,342427783], "departments": [1,2,4,6], "brands 

Java Beginners

MISTAKES CORRECTION - Java Beginners
for your early and helpfull reply. I shall once again to the practical work 

Java Beginners

MISTAKES CORRECTION - Java Beginners
, P.Ravichristy  I used ur code which 

Ajax

JSON-RPC-Java
JSON-RPC-Java       JSON-RPC-Java is an AJAX RPC middleware that allows JavaScript DHTML web applications to call remote methods in a J2EE Application Server and Transparently maps Java 

Java Beginners

converting Json data into rows of DTO in java
converting Json data into rows of DTO in java  I am using jqxgrid, and I am able to access the json data in JAVA controller. But now my requirement...' number of ways to convert this JSON data into rows of DTO. I have used all 

WebSevices Questions

How to connect one application to some othe application through Rest json
How to connect one application to some othe application through Rest json  Hi All, Im new to Rest json How to connect one application to some othe application through Rest json? I need only Rest json plz help 

HTML Questions

call json object using url and represent in html tabular form
call json object using url and represent in html tabular form  how to call json object using url from html and represent in proper format it gives Json object after that i want to arrange the keys-values in table 

HTML Questions

call json object using url and represent in html tabular form
call json object using url and represent in html tabular form  how to call json object using url from html and represent in proper format it gives Json object after that i want to arrange the keys-values in table 

Programming Tutorials

Tutorial, Java Tutorials
Tutorials Here we are providing many tutorials on Java related technologies. All the tutorials are very useful for programmers. You can learn these tutorials very fast. These tutorials are well written and supported with good 

Java Interview Questions

How can I initialize the JSONArray and JSON object with data?
How can I initialize the JSONArray and JSON object with data?  How can I initialize the JSONArray and JSONObject with data 

Java Beginners

import package.subpackage.* does not work
. A.java B.java C.java Below is the code block A.java:- package com.test...(); } } When i am compiling the above 3 class, i am getting an error message like... or make sure it appears in the correct subdirectory of the classpath 

JSP Servlet Questions

How to get jSon object in servlet from jsp - JSP-Servlet
How to get jSon object in servlet from jsp  How to get jSon object in servlet from jsp? In jsp page i have written: var sel... variable in my configurationServlet. Can any one tel me how to get this json 

General

Overloading considered Harmful - Java Tutorials
still be compiled, client code will break: Trying to make a method call where.... In my Java courses, students commonly make this mistake.] What... methods so that similarities become apparent at first sight. It's supposed to make 

JSP Tutorials

JSP Tutorials - Page2
JSP Tutorials page 2 JSP Examples Hello World JSP Page... through the HTML code in the JSP page. You can simply use the <form><... of handling the form through the JSP code. This section provides JSP code which 

Java Beginners

NoughtsAndCrossesGame play button doesn't work
in the above loop but is shown separately here to make // it clearer...NoughtsAndCrossesGame play button doesn't work   /* * To change... main(String[] args) { // TODO code application logic here 

Java Beginners

NoughtsAndCrossesGame play button doesn't work
in the above loop but is shown separately here to make // it clearer...NoughtsAndCrossesGame play button doesn't work   /* * To change... main(String[] args) { // TODO code application logic here 

JEE Technologies

Oracle releases HTML 5 which focuses Java EE 7
, which reduces the need for a related code. It is also to be mentioned here... applications JSON Support:  It simplis data parsing and exchanging using JSON format  Support for RESTful Web Services with JAX-RS 

Java Beginners

Simple program to combine all html,ajax,java,servlets,jsp,json - Java Beginners
, I learned Java,servlets,jsp basics, html, ajax, json and css. I want to do... by ajax, server gets this value using servlet and the change it to json, then the json object was parsed then it will send again to the client page through jsp 

Blog

Site map - C Tutorials
; C Tutorials  | Java Tutorials | PHP Tutorials  | Linux Tutorials | WAP Tutorial  | Struts Tutorial  | Spring FrameWork Tutorial | MySQL Tutorials | XML Tutorial  |  VB 

JSP Tutorials

JSP Tutorials Resource - Useful Jsp Tutorials Links and Resources
JSP Tutorials         ....  By actually typing in the examples and getting them to work, you will gain...-building tools you normally use. You then enclose the code for the dynamic 

Spring 3

Spring MVC Tutorials
Spring MVC Tutorials and example code In this section I will provide you the list of Spring MVC Tutorials which is very useful for a beginner in Spring MVC.... This example of Spring MVC also make you understand about writing the code 

General

Pragmatic Programmer - Java Tutorials
be turned off to make the code run faster. Assertions are a debugging... it amazing how quickly our bodies can deteriorate when we work... Tip 29: Write Code that Writes Code The book obviously expounds 

General

Generic toString - Java Tutorials
can work outside with your notebook during summer... not allow. In the sample code of this newsletter, we will see a Facade...; } /** We specify a different separator for between name and * values to make 

JSON

"JSONArray" example in Java
;     In this part of JSON tutorial you... and String or the JSONObject.NULL objects. To have functionality of JSON in your java program you must have JSON-lib. JSON-lib also requires following " 

JSP Servlet Questions

How to Work - JSP-Servlet
to directly insert java code into jsp file, this makes the development process very... limitations of CGI programs. For read more information,examples and tutorials 

PHP Tutorial

PHP Make Time
PHP  Make Time In PHP, mktime() funtion is used for doing date arithmetic... minute The number of the minute...; To calculate next day use the following code: <?php <?php 

Ajax Examples

Ajax Code Libraries and Tools
, JSON and TEXT ajax transactions. My-BIC has also been tested to work.... These properties make JSON an ideal data-interchange language. JSON is built... Ajax Code Libraries and Tools     

Java-Tutorials

Tutorials on Java
anywhere can make use of them. Tutorials along with Video tutorials, examples... Tutorials on Java Tutorials on Java topics help programmers to learn... and work your way up the ladder by becoming proficient in the language. Following 

General

Java Swing Tutorials
Java Swing Tutorials       Java Swing tutorials -  Here you will find many Java Swing examples with running source code. Source code provide here are fully tested 

Submit-Tutorials

Submit Tutorials - Submitting Tutorials at RoseIndia.net
Submit Tutorials       Submitting Tutorials at RoseIndia.net is very easy. We welcome all members to submit their tutorials at RoseIndia.net. We are big tutorial web site 

Java-Tutorials

Catching Exceptions in GUI Code - Java Tutorials
the given below code to identify the uncaught exception : import...); gui.show(); } } First we compile and run this code using javaw.exe... stay pressed. When you run the same code using java.exe you will get 

General

Treating Types Equally - Java Tutorials
(editor@dev/null). But don't moan. I want to thank all those who make... good work. It makes the newsletter more useful when we remove the Gremlins... for unsigned integral values, but they did not make it, so why do we have 

General

OutOfMemoryError Warning System - Java Tutorials
Orientation? Is the dream of writing reusable code just that - a dream..., why assert is dangerous, how generics work, plus a demonstration.... JDK 1.5 has added some wonderful new management beans that make writing 

General

MemoryCounter for Java 1.4 - Java Tutorials
. Maximum Solutions (my company) is hoping to do some work together... classes that will only work for Java 1.4 onwards. In addition, the memory..., then such an approach would make sense. My approach is used for measuring RAM memory 

Java Beginners

why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...   public class d55 { int squares = 81; public static void main(String 

Software Development

HTML5 Tutorials
HTML 5 Tutorials In this section we have listed the tutorials of HTML 5... of HTML5  is to make browser as a application platform. Now HTML5 allows you... of HTML5 which helps the developers to make attractive UI for their web 

JSP Tutorials

JSF - Java Server Faces Tutorials
JSF - Java Server Faces Tutorials Complete Java Server Faces (JSF) Tutorial - JSF Tutorials. JSF Tutorials at Rose India covers... JSF tutorial comes with free source code and configuration files 

General

Controlling Machines Remotely with Java - Java Tutorials
code that would work with JDK 1.3, so that it is possible to control computers... greatly. This then flows into my work, into my newsletter, and back... and wonderful things. Whilst I have not tried it out, it should also work cross 

Java-Tutorials

Java HashMap - Java Tutorials
; map = new HashMap<String, Object>(); The difference between the above... implementation without any code compatibility problem. But this is not possible... the hash code for the invoking map. boolean isEmpty( )  Returns 

Struts 2 Tutorials

What are Interceptors in Struts 2 and how do they work?
What are Interceptors in Struts 2 and how do they work? Understanding Struts 2.... Interceptors performs very important work during pre and post processing of any request... of interceptors is their ability to execute code before and after an Action is invoked 

Servlets

Java : Servlet Tutorials
() function, which runs the code after every 1 minute... Java : Servlet Tutorials     ... easier to use Tomcat for learning Java Servlet. These step-by-step tutorials 

Java-Tutorials

Java Video Tutorials for beginners
Java Video Tutorials for beginners are being provided at Roseindia online for free. These video tutorials are prepared by some of the best minds of Java... tutorials showcase the practical implementation of programming, how a program 

General

Many Public Classes in One File - Java Tutorials
protection. This can easily result in spaghetti code that would make... make an "exe". Every Java class has to be in a separate file... for this restriction is to make the compilation process faster. This newsletter 

General

Doclets Find Bad Code - Java Tutorials & Doclets Tutorial
to make sure that his exercises did not contain "bad code" by mistake, so... make code bad. Inappropriate variable names, making data members non-private...(cd.innerClasses()); } } The code above is dead-easy, but how do you use 

General

GoF Factory Method in writing GUIs - Java Tutorials
of the code, since the auto-generated code is difficult to work with. In addition, if we change too much of the code, we will not be able to work with the RAD GUI... can apply the Factory Method in other code. In the long run, it will make 

General

Initialising Fields before Superconstructor call - Java Tutorials
are supposed to work like an apprenticeship. This is for South African citizens...().getClass()); } } What happens when you run that code? To my... that springs to mind is inheritance. Instead of having one CustomerView, we make 

General

Java 5 - "final" is not final anymore - Java Tutorials
would make Java code more maintainable. Due to Java 5 having just been released, none of them had started using generics in production code... that we could not make an array constant, and that there was no way of protecting 

General

TristateCheckBox based on the Swing JCheckBox - Java Tutorials
this to work: You have to overwite addMouseListener() to do... the focus. You have to make a TristateDecorator as a button model.... Let's look at the code: import javax.swing.*; import 

General

Ego Tripping with Webservices - Web Services Tutorials
, I had my nose against the grindstone, typing Java code at neck... to mention that Clark Updike sent me a similar code snippet to what I used... Solutions and learn how to write excellent, efficient, good Java code 

Ajax Examples

jQuery - jQuery Tutorials and examples
jQuery - jQuery Tutorials and examples   ... and jQuery Tutorials on the web. Learn and master jQuery from scratch. jQuery is nice piece of code that provides very good support for ajax. jQuery can be used 

Servlets

Servlet Tutorials Links
Servlet Tutorials Links      ... tutorial for writing HTTP Servlets with complete source code for the example Servlets.... What is servlet: Servlets are modules of Java code that run 

General

Welcome to the MySQL Tutorials
MySQL Tutorial - SQL Tutorials   ... the password then make new user .This lesson you learn how to create new... popular database and make quick easy to store or its access, and update 

Java Beginners

how make excel
); } } } For the above code, you need Apache POI library. Thanks...how make excel  how make excel spreadsheet IN JAVA. please send this code argently   Hello Friend, Try the following code: import 

General

Exception in Java - Java Tutorials
you compile the above code, you will get an error something like...;);} } Amazingly the above code compile without any hassle. Now, we try to run...Commenting Erroneous Code & Unicode newline Character In this section, you 

Java Beginners

how to make multiple rectangles
. please help my code as of now:(but this doesn't work) import java.awt.Color...how to make multiple rectangles  I,m a beginner , m sorry...(JFrame.EXIT_ON_CLOSE); //Set JFrame size setSize(400,400); //Make JFrame 

Ajax-Tutorial

Ajax Tutorials
these technologies work together - from an overview to a detailed look -- to make... Ajax Tutorials      ... computer. They might use the Internet to download updates, but the code 

Programming Tutorials

Java Tutorials - JDK Tutorials, JAVA Examples, JDK Examples
Appendix 3: Source Code for All Examples in this Book News and Errata... all or part of the text. The following PDF file is provided to make 

General

Resetting ObjectOutputStream - Java Tutorials
of using sun.* classes in your code, since it would make your Java code... "the best" at training, we make sure that all our trainers are active...) { this.age = age; } } Next we have the code 

General

Wait Cursor - Java Tutorials
this (if you have access to the dialog code) is to make the dialog non-modal... components. Why does it work this way? Well, that's a topic for another...); frame.setVisible(true); } } I'm not going to discuss all the Swing code 

General

sun.reflect.Reflection Package - Java Tutorials
classes for making soup. (In case you want to make a nice vegetable soup... = new Potato(4); soup.add(p4); p4.setSoup(soup); // redundant code 

General

Java and Dilbert - Java Tutorials
. Wally would be the person I would make in charge of automating the build process of the code, and running the unit tests. You can bet that there would... to the advertising anymore. Here's the code: import java.io.*; import java.net.URL 

Database-Tutorials

What is the difference between MongoDB and MySql?
than MySql will work perfectly but if a data is complex and you want to store serialized arrays or JSON objects then MongoDB is advised. MySql has JOIN operation, which allows it to work across multiple tables while MongoDB does 

Programming Tutorials

C++Tutorials
benefit to download the source code for the example programs, then compile... other tutorials, such as C++: Annotations by Frank Brokken and Karel Kubat...; The CPlusPlus Language Tutorial These tutorials explain the C++ language 

General

Java Field Initialisation - Java Tutorials
; } } In the above code you might me thinking that what is the necessity to initialize the variable above. But when you compile the above code... the initialization code is copied into all the constructor. For Example public 

Advertisements Advertisements
 

 

 

DMCA.com