• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

how to convert nested json data into pojo in spring?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got json data from api like {"id":"{"$id" : "126geto89900ok650"},
"student_rollno" : "1234567",
"student_answers": [{"1" :"5"}, {"2" : "5"},{"3","4"}],
"mother_answer": " " }


how can I convert this json data to pojo . I can do simple json data conversion. And also how to check weather incoming values are empty or not like mother variable is empty sp please suggest me how to do that ?
 
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
shivmaruti singh,

Is this an API response? If so can you show us how you tried to get this response to you controller?
 
shivmaruti singh
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes this is Api response . i used



where uri is API url.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shivmaruti singh wrote:yes this is Api response . i used...


Just as an aside, I'm not wild about those auto-generated catch blocks. Why not:
  throw new Error(e);
instead?

It's nothing to do with you, but as it stands that code would just spew out a stacktrace every time it got an error, and merrily continue processing - and you might never know that it had a problem until you ended up with a NullPointerException.

Winston
 
shivmaruti singh
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone can suggest me how to convert given json into pojo in controller please its urgent.
 
Partheban Udayakumar
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
shivmaruti singh,

You can use something like Map<String, object> to handle this. Can you show us your ReportComingValues class?

shivmaruti singh wrote:anyone can suggest me how to convert given json into pojo in controller please its urgent.



People answering here are from different time zones, so please be patient
 
shivmaruti singh
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.
I know people works from different timezone. but actually My project have stopped just for conversion of json to pojo.



but it not work it is showing exception.

 
Partheban Udayakumar
Ranch Hand
Posts: 499
Spring AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shivmaruti singh wrote: {"id":"{"$id" : "126geto89900ok650"},
"student_rollno" : "1234567",
"student_answers": [{"1" :"5"}, {"2" : "5"},{"3","4"}],
"mother_answer": " " }



This response is not of the type Map<String, Integer> its actually of the type Map<String, Object>
 
shivmaruti singh
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone can please suggest me that what will be the suitable pojo structure for this given json . I tried much but did not solve .
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic