Trying to use Spring Boot REST to Read JSON String from POST

前端 未结 5 1557
谎友^
谎友^ 2020-12-04 09:46

Am using the latest version of Spring Boot to read in a sample JSON via Restful Web Service...

Here\'s my pom.xml:



        
5条回答
  •  感动是毒
    2020-12-04 10:11

    To add on to Andrea's solution, if you are passing an array of JSONs for instance

    [
        {"name":"value"},
        {"name":"value2"}
    ]
    

    Then you will need to set up the Spring Boot Controller like so:

    @RequestMapping(
        value = "/process", 
        method = RequestMethod.POST)
    public void process(@RequestBody Map[] payload) 
        throws Exception {
    
        System.out.println(payload);
    
    }
    

提交回复
热议问题