Skip to content

PropertyNamingStrategy

Paul Brown edited this page Oct 19, 2011 · 1 revision

Jackson Glossary: PropertyNamingStrategy

  • Package: org.codehaus.jackson.map
  • Jar: jackson-mapper

Role

PropertyNamingStrategy is an abstract class that defines simple way to customize way POJO property names are converted to matching JSON property names. Default implementation simply returns suggested name (which is derived from methods as per Java Bean specification; and for fields is simply field name as-is).

Sub-class of this class can be used in cases where naming convention used in JSON format differs from Bean convention: for example when naming convention is

  • C-style: underscore between words, all lower case
  • C++/Microsoft style: similar to Bean properties, but all words (including the first one) are capitalized, not just all-but-first.

See JacksonFeaturePropertyNamingStrategy for more information

Usage

Custom implementation are registered with ObjectMapper:

  ObjectMapper mapper = new ObjectMapper();
  mapper.setPropertyNamingStrategy(new MyNamingStrategy());

and take effect for both serialization and deserialization.


Back to JacksonTermGlossary


CategoryJackson