How can I make a specific httpclient to deserialize camel case json

1k views Asked by At

I implement an API server with Finatra and my api outputs snake case json, i.e.;

case class A {
  val someProperty: String
}

val a = A("value")

a will be serialized int the json and vice versa

{"some_property":"value"}

But I have to access 3rd party API with camelcase json I/O, which represent above object with

{"someProperty":"value"}

I get object MyClientModule extends HttpClientModule via guice injector. How can I override/change jackson configuration to a specific httpclient?

1

There are 1 answers

0
Shouichi On

HttpClientModule implicitly use FinatraObjectMapper. Though you can configure FinatraObjectMapper to serialize/deserialize JSON with camelCase, it affects the behavior globally. One simple way is to explicitly explicitly instantiate HttpClient with your camelCase object mapper. The another way is to define custom http client and its provider module.