How can I find the JSON key of a field (jackson)? How can I find the JSON key of a field (jackson)? json json

How can I find the JSON key of a field (jackson)?


You should use jackson introspection instead of pure java reflection. It will allow you to discover json properties mapped to java fields/methods according to your serialization config.

JavaType userType = mapper.getTypeFactory().constructType(User.class);BeanDescription introspection =    mapper.getSerializationConfig().introspect(userType);List<BeanPropertyDefinition> properties = introspection.findProperties();// do some processing over properties...