Package com.guinetik.rr.json
Class JsonObjectMapper
- java.lang.Object
-
- com.fasterxml.jackson.core.TreeCodec
-
- com.fasterxml.jackson.core.ObjectCodec
-
- com.fasterxml.jackson.databind.ObjectMapper
-
- com.guinetik.rr.json.JsonObjectMapper
-
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned,Serializable
public class JsonObjectMapper extends com.fasterxml.jackson.databind.ObjectMapperPre-configured JacksonObjectMapperwith utility methods for JSON operations.This class extends Jackson's ObjectMapper with RocketRest-specific configuration and provides convenient static methods for common JSON serialization and deserialization tasks.
Default Configuration
- Field visibility: ANY (serializes private fields)
- Getter/Setter visibility: NONE (ignores getters/setters)
- Indented output: enabled
- Unknown properties: ignored
- Null values: excluded from output
Object Serialization
User user = new User("John", "john@example.com"); // To JSON string (indented) String json = JsonObjectMapper.toJsonString(user); // To JSON string (compact) String compact = JsonObjectMapper.toJsonStringNoIdent(user);Object Deserialization
String json = "{\"name\":\"John\",\"email\":\"john@example.com\"}"; // To typed object User user = JsonObjectMapper.jsonToObject(json, User.class); // To Map Map<String, Object> map = JsonObjectMapper.jsonToMap(json); // To List of Maps String arrayJson = "[{\"id\":1},{\"id\":2}]"; List<Map<String, Object>> list = JsonObjectMapper.jsonToListOfMap(arrayJson);JsonNode Operations
JsonNode node = JsonObjectMapper.getJsonNode(json); String name = node.get("name").asText(); Map<String, Object> map = JsonObjectMapper.jsonNodeToMap(node);Singleton Access
// Get pre-configured singleton instance ObjectMapper mapper = JsonObjectMapper.get(); // Get fresh default-configured mapper ObjectMapper fresh = JsonObjectMapper.getDefault();- Since:
- 1.0.0
- Author:
- guinetik <guinetik@gmail.com>
- See Also:
ObjectMapper, Serialized Form
-
-
Field Summary
-
Fields inherited from class com.fasterxml.jackson.databind.ObjectMapper
_coercionConfigs, _configOverrides, _deserializationConfig, _deserializationContext, _injectableValues, _jsonFactory, _mixIns, _registeredModuleTypes, _rootDeserializers, _serializationConfig, _serializerFactory, _serializerProvider, _subtypeResolver, _typeFactory, DEFAULT_ANNOTATION_INTROSPECTOR, DEFAULT_BASE
-
-
Constructor Summary
Constructors Constructor Description JsonObjectMapper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.databind.ObjectMapperget()static com.fasterxml.jackson.databind.ObjectMappergetDefault()static com.fasterxml.jackson.databind.JsonNodegetJsonNode(String json)static Map<String,Object>jsonNodeToMap(com.fasterxml.jackson.databind.JsonNode json)static List<Map<String,Object>>jsonToListOfMap(String json)static Map<String,Object>jsonToMap(String json)static <T> TjsonToObject(String json, Class<T> type)static Map<String,Object>parseResponse(HttpURLConnection connection)static StringtoJsonString(Object model)static StringtoJsonStringNoIdent(Object model)-
Methods inherited from class com.fasterxml.jackson.databind.ObjectMapper
_assertNotNull, _checkInvalidCopy, _configAndWriteValue, _constructDefaultTypeResolverBuilder, _convert, _findRootDeserializer, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializerProvider, _verifyNoTrailingTokens, _verifySchemaType, _writeValueAndClose, acceptJsonFormatVisitor, acceptJsonFormatVisitor, activateDefaultTyping, activateDefaultTyping, activateDefaultTyping, activateDefaultTypingAsProperty, addHandler, addMixIn, addMixInAnnotations, canDeserialize, canDeserialize, canSerialize, canSerialize, clearProblemHandlers, coercionConfigDefaults, coercionConfigFor, coercionConfigFor, configOverride, configure, configure, configure, configure, configure, configure, constructType, constructType, convertValue, convertValue, convertValue, copy, copyWith, createArrayNode, createDeserializationContext, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createObjectNode, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, deactivateDefaultTyping, defaultClassIntrospector, disable, disable, disable, disable, disable, disable, disable, disableDefaultTyping, enable, enable, enable, enable, enable, enable, enable, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTypingAsProperty, findAndRegisterModules, findMixInClassFor, findModules, findModules, generateJsonSchema, getDateFormat, getDeserializationConfig, getDeserializationContext, getFactory, getInjectableValues, getNodeFactory, getPolymorphicTypeValidator, getPropertyNamingStrategy, getRegisteredModuleIds, getSerializationConfig, getSerializerFactory, getSerializerProvider, getSerializerProviderInstance, getSubtypeResolver, getTypeFactory, getVisibilityChecker, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, missingNode, mixInCount, nullNode, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, readerFor, readerFor, readerFor, readerForArrayOf, readerForListOf, readerForMapOf, readerForUpdating, readerWithView, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValues, readValues, readValues, readValues, registerModule, registerModules, registerModules, registerSubtypes, registerSubtypes, registerSubtypes, setAccessorNaming, setAnnotationIntrospector, setAnnotationIntrospectors, setBase64Variant, setConfig, setConfig, setConstructorDetector, setDateFormat, setDefaultAttributes, setDefaultLeniency, setDefaultMergeable, setDefaultPrettyPrinter, setDefaultPropertyInclusion, setDefaultPropertyInclusion, setDefaultSetterInfo, setDefaultTyping, setDefaultVisibility, setFilterProvider, setFilters, setHandlerInstantiator, setInjectableValues, setLocale, setMixInAnnotations, setMixInResolver, setMixIns, setNodeFactory, setPolymorphicTypeValidator, setPropertyInclusion, setPropertyNamingStrategy, setSerializationInclusion, setSerializerFactory, setSerializerProvider, setSubtypeResolver, setTimeZone, setTypeFactory, setVisibility, setVisibility, setVisibilityChecker, tokenStreamFactory, treeAsTokens, treeToValue, treeToValue, updateValue, valueToTree, version, writer, writer, writer, writer, writer, writer, writer, writer, writer, writer, writerFor, writerFor, writerFor, writerWithDefaultPrettyPrinter, writerWithType, writerWithType, writerWithType, writerWithView, writeTree, writeTree, writeValue, writeValue, writeValue, writeValue, writeValue, writeValueAsBytes, writeValueAsString
-
-
-
-
Method Detail
-
getJsonNode
public static com.fasterxml.jackson.databind.JsonNode getJsonNode(String json)
-
jsonNodeToMap
public static Map<String,Object> jsonNodeToMap(com.fasterxml.jackson.databind.JsonNode json)
-
getDefault
public static com.fasterxml.jackson.databind.ObjectMapper getDefault()
-
get
public static com.fasterxml.jackson.databind.ObjectMapper get()
-
parseResponse
public static Map<String,Object> parseResponse(HttpURLConnection connection) throws IOException
- Throws:
IOException
-
-