java, Gson

카테고리 없음 2021. 9. 24. 17:52
$ cat build.gradle
...
dependencies {
....

implementation 'com.google.code.gson:gson'
...
}
...

$ cat GsonTest.java
...
import com.google.gson.GsonBuilder;
...
        String req = new GsonBuilder().create().toJson(obj);
        ...
                Mono<String> result = webClient.mutate()
                .build()
                .post()
                .uri(uri)
                .header("Content-Type", "application/json")
                .header("openapikey", openapikey())
                .bodyValue(req)
                .accept(MediaType.APPLICATION_JSON)
                .retrieve()
                .bodyToMono(String.class);