How to send complex JSON structure from angular to spring controller



I've a JSON like below in my angular controller, which i need to post to Spring controller.

var items={"A":"aa",
           "B":"bb",
           "C":{"D":"dd", "E":"ee"}
           };

$http.post('localhost:8082/ProjectName/posting',items)
.success(function(data,status,headers, config){
   alert("success");
})
.error(function(error){
    alert(error);
});

In my Spring controller

@RestController
public class ForPost{
  @RequestMapping(value="/posting",method=RequestMethod.POST)
  public @ResponseBody List  forPosting(@RequestBody PostingModel
postingModel){
    System.out.println("Print all values received");
    .
    .
    .
    .
  }
}

I'm thinking for this kind of nested JSON, I need to have nested POJO. something like:

public class PostingModel{
 String A;
 String B;
 POJOForC C;
 /* getter setter below*/
}

puublic class POJOForC{
 String D;
 String E;
 /* getter setter below*/
}

I get error message: The request sent by client was syntactically incorrect(). Am I accepting the values correctly? Need to fix something in POJO?


Related to : How to send complex JSON structure from angular to spring controller

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .