if you want a single http request header to be "injected" into your controller method (as an argument) by Spring try it this way:
@RequestMapping("/your-path")
public ResponseEntity<MyObject> getStuff(@RequestHeader("My-Header") String jsonValue) {
//...
}
also see here: https://www.viralpatel.net/spring-requestheader-example/
you can also try to implement a custom converter, see here for an example:
https://stackoverflow.com/a/50996349/150623
the way to go would be to use an ObjectMapper instance from the Jackson lib to convert the JSON string to a java.util.Map object...
could work this way (not tested though):
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
@Component
public class JsonToMapConverter implements Converter<String, Map<String,String>> {
private ObjectMapper objectMapper = new ObjectMapper();
@Override
public Map<String, String> convert(final String json) {
try {
return objectMapper.readValue(json, Map.class);
} catch (IOException e) {
//handle exception...
}
}
}
don't forget to add Jackson to your dependencies, e.g. in Maven:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>