Repository navigation
0.2.2
How to integrate Jackson with Dotenvx?
You can integrate Jackson with Dotenvx to protect some sensitive fields, such as SSN, email or phone number.
ObjectMapper getDotenvxObjectMapper() {
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(new DotenvxGlobalJsonSerializer(publicKey));
return JsonMapper.builder().addModules(simpleModule).build();
}
@Test
public void testJsonSerialize() throws IOException {
Map<String, String> info = new HashMap<>();
info.put("email", "private:demo@example.com");
info.put("nick", "Jackie");
final String jsonText = objectMapper.writeValueAsString(info);
System.out.println(jsonText);
}If text value prefixed with private:, and the value will be encrypted.