1

I have the following method:

public String getUTResult() throws IOException {

     BuildResultParser bp = new BuildResultParser();
     BuildResultBean b = bp.getreadFile("C:\\bc.txt");

     String str = b.getuTresult();

     return str;

Now str variable contains the value as: [0,5,5]

Now I need to pass this value to ajax call in javascript in following format:

unittest
   {
     fail:0
     pass:5
     total:5
   }

Actually in javascript, I need this data in array format so that I can access each value and do some processing.

Brian
  • 1,184
  • 2
  • 21
  • 38
user2315104
  • 2,378
  • 7
  • 35
  • 54

1 Answers1

0

Read this : http://hmkcode.com/java-servlet-send-receive-json-using-jquery-ajax/ or any example of converting data to json format.

If your requirement is limited to the example, u can have another function which takes str and creates json data out of it, in the format required by you.

willowherb
  • 837
  • 1
  • 13
  • 21
  • i am using jersy as of now and i dont want to use jquery – user2315104 Dec 04 '13 at 02:22
  • i dont know anyrhing about jquery , so is there any another way to generate such data – user2315104 Dec 04 '13 at 02:24
  • Check this : http://stackoverflow.com/questions/15786129/converting-java-objects-to-json-with-jackson and http://www.mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/ Its not about jquery... Converting your object to a json object is a java code.. look at the java code in the examples.. – willowherb Dec 04 '13 at 05:19
  • u might want to read this - http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work Always either accept an answer or post your own answer & mark it as the correct answer(if none of the answers provided is acceptable).. – willowherb Dec 04 '13 at 08:51