Skip to content

0.2.2

Choose a tag to compare

@linux-china linux-china released this 24 Sep 04:46
· 30 commits to main since this release

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.