0

How to Create a Restful service for a Huge JSON data using Java eclipse Tomcat7.0

Hi every one ,.. I need need to create a Restful web service which will gice Json data ,..

a Json data which contains number of Json arrays,... i need to do this with Tomcat and java in eclipse,.. If possible give me a tutorial which is on this point with a Big Json data,... Thankyou,.

7
  • 2
    Atleast do google once before posting a question. Commented Nov 20, 2013 at 4:37
  • hi i googled but i am getting maven or netbeans not exact one,.. i spent time on that only,.. i need it with Tomcat java Restful JOSN data Commented Nov 20, 2013 at 4:48
  • i think so this will satisfies your requirement jeeconsultant.com/sites/jeeconsultant.nsf/docs/… Commented Nov 20, 2013 at 4:51
  • yes sir,.. i need to work with XML thaks all for this ,... if possible tell me how to give a JSON Data with a lot of JSON array and objects,.. Commented Nov 20, 2013 at 4:53
  • do you mean that you want java to create a json with many arrays and objects Commented Nov 20, 2013 at 4:56

1 Answer 1

0

Is your Google down!!! There are a lots of good stuffs available in Google related with REST web-service.

Anyway Take a look at this stuff

Building a Simple RESTful Web Service to produce JSON using Jersey

Developing REST Web Services in Eclipse

For creating a JSON see this example
Say you want to create a JSON as shown below

{"subitem":
 [{"rate":"123",
   "baseitem":"148",
   "item":"HIJ",
   "section":"pub",
   "imagename":"pic.png"
 }],

 "hoteltables":
 [{"tableno":"123",
   "status":"active",
   "section":"pub",
   "custid":"12"
 }],

 "mainiteam":
 [{"status":"available",
   "item":"ABC",
   "itemid":"12",
   "section":"pub",
   "imagename":"XYZ"
 }]
}

The java code for creating the above JSON is as given below

JSONArray obj = new JSONArray();
JSONObject jsonobj=new JSONObject();

HashMap rows=new HashMap();
rows.put("tableno","123");
rows.put("status","active");
rows.put("section","pub");
rows.put("custid","12");
obj.put(rows);

jsonobj.put("hoteltables", obj);

obj = new JSONArray();

rows=new HashMap();
rows.put("itemid","12");
rows.put("item","ABC");
rows.put("status","available");
rows.put("section","pub");
rows.put("imagename","XYZ");
obj.put(rows);

jsonobj.put("mainiteam", obj);

obj = new JSONArray();
rows=new HashMap();
rows.put("baseitem","148");
rows.put("item","HIJ");
rows.put("rate","123");
rows.put("section","pub");
rows.put("imagename","pic.png");
obj.put(rows);

jsonobj.put("subitem", obj);

System.out.println(jsonobj.toString());
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for Responce sir,... i will try with first one ,. by second one is My eclipse I am using Eclipse and tomcat,.. its ok i will go with first one i have a big JSON data do on this,.. so i am thinking is there any other way with java JSON Tomcat,.. Eclipse J2ee,... Thank You sir,....
it doesn't matter how big your JSON data is. since java has json libraries which can be parse JSON easily better than XML.
is there any example for Json Data for Big files if there give me links ,... But it has to follow on JSON RESTFUL eclipse tomcat,...
Hi Nidhishkrishnan sir,.. in the above code can you how to use this with example which is mentioned on jeeconsultant.com/sites/jeeconsultant.nsf/docs/… can you tell me,..
The link with the example is broken

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.