• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to generate an JSON object in a JSON Array oin Spring Rest Web Service Design?

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I am designing a REST JSON Web Services using Spring Controller.My Requirement is I want to generate a JSON response as
JSON Object then JSON Arrays inside it.
JSON Array then JSON objects inside it

this is my code that I am using


where EmployeeGeneralInfo is a Model class

and I am getiing response like this


{"empFirstName":"Kishor","empEmail":"kishorjoshi120@gmail.com","empMob":"phone","empCategory":"Employee","empDept":"Tech","empSubDept":"IT","empImage":"YWJjLmpwZWc="}



What I want something like this
{
"myfirstObject"
[
"attribute":"value1"
"attribute2":"value2"
]
,
[
"attribute1":"value1"
"attribute2":"value2"
]
}

something like this which we use in JSONObject jsonObject=new JSONObject() like this notation

Is it possible to construct like this JSON in Spring REST?

Thanks
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out https://code.google.com/p/google-gson/
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Maneesh

Thanks
 
Goodbye moon men. Hello tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic