I am getting Json array from mobile side and want to parse the Json in server side using Java and jersey and Gson. I am sending the JSON array in POST method from iOS. I want to consume the json but stuck on how do i save the json data in Java class. This is the structure of my Json arrayentities:{"stores":[{"tills":[{"name":"b1 till1"}],"name":"b1 store"},{"tills":[{"name":"b2 till2"}],"name":"b2 store"}],"name":"B mart"}
entities:{"stores":[{"tills":[{"name":"c1 till1"}],"name":"c1 store"},{"tills":[{"name":"c2 till2"}],"name":"c2 store"}],"name":"C mart"}
name:Dmart
            Asked
            
        
        
            Active
            
        
            Viewed 337 times
        
    0
            
            
         
    
    
        babu
        
- 11
- 3
- 
                    A similar question has been answered at: http://stackoverflow.com/questions/31073624/how-to-convert-json-objects-to-pojo-from-gson – aavos May 11 '17 at 05:57
- 
                    my json array response from mobile side is different i want parse in following format. – babu May 11 '17 at 06:17
1 Answers
-1
            
            
        I think you have to do simply like this: This is a code snippet i used in one of my test-applications
To parse JSON you need in my example the GSON-Library
@Path("/FriendsList")
public class RestWebServicesAPI{
@POST
@Path("/friends")
@Consumes(MediaType.APPLICATION_JSON)
public Friends saveFriendList(final String json){
    Gson gs = new Gson();
    Friends [] n = gs.fromJson(json, Friends [].class);
}
//ALTERNATIVE
@POST
    @Path("/friends")
    @Consumes(MediaType.APPLICATION_JSON)
    public Friends saveFriendList(final Friends[] friends){
    }
 
    
    
        FrankTheTank_12345
        
- 560
- 3
- 12