• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to convert JSON Array to arraylist

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm receiving data in form of JSON Array. Here's the JSON Array that i've received :
[{"FOODID":"Jus Alpukat","PRICE":"7000","NUM":"1","RES":"7000.0","ORDERID_FK":""},{"FOODID":"Ice Cream","PRICE":"5000","NUM":"10","RES":"50000.0","ORDERID_FK":""}]

i need it to be converted into arraylist that will be inserted into JTable into java. I've read about GSON and a few article to do this but i still don't understand. Can you give me example how to do this? thanks.
 
Greenhorn
Posts: 7
Hibernate Spring Redhat
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Melody Putri wrote:Hi,

I'm receiving data in form of JSON Array. Here's the JSON Array that i've received :
[{"FOODID":"Jus Alpukat","PRICE":"7000","NUM":"1","RES":"7000.0","ORDERID_FK":""},{"FOODID":"Ice Cream","PRICE":"5000","NUM":"10","RES":"50000.0","ORDERID_FK":""}]

i need it to be converted into arraylist that will be inserted into JTable into java. I've read about GSON and a few article to do this but i still don't understand. Can you give me example how to do this? thanks.



Hi Melody,

You can use jackson library to convert json object to arraylist,

first, you need to create a POJO



second , create a method that convert to ArrayList Object, let say a convert method.



Hope it helps
 
Marshal
Posts: 79401
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
reply
    Bookmark Topic Watch Topic
  • New Topic