• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert List To Json Data  RSS feed

 
bharat salunkhe
Greenhorn
Posts: 25
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have list of object and i want convert in specific formatted json as follows..
{
"Result":"OK",
"Records":[
{"PersonId":1,"Name":"Benjamin Button","Age":17,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":2,"Name":"Douglas Adams","Age":42,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":3,"Name":"Isaac Asimov","Age":26,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":4,"Name":"Thomas More","Age":65,"RecordDate":"\/Date(1320259705710)\/"}
]
}

my current code is


and my current output is

+++[[100,"CWR",null,null,"11","B5A","IC",0,null,null,null,null,null,null],[20,"LO",null,null,"11","B5A","IH",0,null,null,null,null,null,null],[15,"RP",null,null,"555","B5A","IC",0,null,null,null,null,null,null],[15,"CWR",null,null,"22","B5A","IC",0,null,null,null,null,null,null]]



is there any solution ??
 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really want to clean up that code (especially that looooong line). Oh and use code tags here, they make reading code a lot easier.

Also, what is JSONObject? One of your own classes, or a part of some framework? Apparently that class is supposed to create the JSON, but without knowing more how it works, its impossible to tell why it creates the output you see.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@bharat salunkhe: Please UseCodeTags (← click) and use lines of less than 120 chars when posting code as it makes it easier for people to read your code. I've sorted it for you this time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!