Reputation: 9411
I have a POJO object that has UpperCamelCase naming. When I do the call to Jackson's ObjectMapper to serialize/marshal it to JSON, the result is lowerCamelCase for field names.
The call is now trivial:
ObjectMapper objectMapper = new ObjectMapper();
jsonText = objectMapper.writeValueAsString(myObjectToJson);
how I can tell ObjectMapper to make UpperCamelCase? Or is it some sort of set-in-stone JSON standard?
I use jackson inside Apache Camel.
Upvotes: 2
Views: 1193
Reputation: 2101
edited original answer.
Jackson uses camelCasing as default it seems. They have implemented a PascalCasing strategy. Try this:
ObjectMapper mapper = new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.PASCAL_CASE_TO_CAMEL_CASE);
Or annotate your fields with @JsonProperty("UpperCaseProperty")
Upvotes: 2