Skip to content

Instantly share code, notes, and snippets.

@push-gists push-gists/JacksonContext.java Secret
Last active Apr 27, 2016

Embed
What would you like to do?
Provides a shared context for using Jackson
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
You can’t perform that action at this time.