Announcement Announcement Module
No announcement yet.
How to POST json into Spring Roo using REST Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to POST json into Spring Roo using REST

    I've got a class structure, of the following:

    class entity
    String Name
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "xxxxx")
    private Set attributes = new HashSet();
    private Useraccount useraccount;

    And I want to use the JSON Controller to post a JSON format in the body to insert the record into my database.

    Its a similar stucture of the following:

    @RooWebJson(jsonObject =xxxx.class)
    public class RecipeAPIConroller {x
    @RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
    public ResponseEntity<String> createFromJson(@RequestBody String json) {
    XXXXXX xxxxx = XXXXX.fromJsonToxxxxx(json);
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/json");
    return new ResponseEntity<String>(headers, HttpStatus.CREATED);


    What is the json file ssuppose to look like in the POST? Is there documentation I can read that will explain how it works?

    Also, how do I map the useraccount with the original class so when I use entity.persist for example it creates the record?