java - need to JSON output? -


here i'm creating 1 product list in java. need product list json. how ?

private list<productfromservicetemp> getlistfromwebservice()      {          list<productfromservicetemp> productlist = new arraylist<productfromservicetemp>();         for(int = 0; < 10; i++)         {             productfromservicetemp product = new productfromservicetemp();             product.setname("name " + i);             product.setdescription("desc " + i);             product.setprice(i * 100d);             productlist.add(product);             system.out.println("product = " + product);             system.out.println("productlist = " + productlist);         }          return productlist;     } 

so

`array ar = [prod1, prod2];` 

then

ar[i].name ar[i].price 

how product detail? please 1 me.

i recommend have @ gson. => http://code.google.com/p/google-gson/

gson java library converts java objects json objects. ;)

i discovered yesterday. it's great; quick , efficient.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -