I'm using Jackson 2.9.2
and Retrofit 2.1.0
for some POST
operation with a JSONArray
as HTML-Header
parameter.
The API defines a value which is aId
. No matter what I try, my JSON property
is always converted to lowercase (aid
).
I tested my same code with abId
, and it works... Anyone a clue, where my configuration is wrong or which convention(?) is against this property name?
//ObjectMapper initialization
ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
//the data class
import com.fasterxml.jackson.annotation.JsonProperty
data class MyClass(
@JsonProperty
val aId: String? = null, //<-- not working
@JsonProperty
val abId: String? = null //working!
)
//Retrofit call
import retrofit2.http.Body
@POST("log")
fun sendLog(@Body logs: List<MyClass>): Call<MyCall>
//JSON Result in HTML Header
[{
"aid":"some_value", //should be "aId"
"abId":"some_value" //is correct
}]
I tried with following Annotations:
@SerializedName("aId")
@JsonProperty("aId")
@JsonRawValue
@JsonAlias