-
-
Save push-gists/a01f11981fd60fd42fd18397b31b8b21 to your computer and use it in GitHub Desktop.
Provides a shared context for using Jackson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum JacksonContext { | |
INSTANCE; | |
private final CBORFactory factory = new CBORFactory(); | |
private final ObjectMapper mapper = new ObjectMapper(factory); | |
public static Map<String, Object> jsonToMap(JSON json) throws IOException { | |
try (CBORParser parser = INSTANCE.factory.createParser(json.asInputStream())) { | |
return INSTANCE.mapper.readValue(parser, new TypeReference<Map<String, Object>>() { }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment