public.javadoc.org.spincast.plugins.jacksonjson.SpincastJsonManager.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
The newest version!
SpincastJsonManager (org.spincast:spincast-framework 0.9.28 API)
org.spincast.plugins.jacksonjson
Class SpincastJsonManager
- java.lang.Object
-
- org.spincast.plugins.jacksonjson.SpincastJsonManager
-
- All Implemented Interfaces:
- IJsonManager
public class SpincastJsonManager
extends Object
implements IJsonManager
Spincast Jackson Json manager
-
-
Constructor Summary
Constructors
Constructor and Description
SpincastJsonManager(com.google.inject.Provider<com.google.inject.Injector> guiceProvider,
IJsonObjectFactory jsonObjectFactory,
Set<IJsonMixinInfo> jsonMixinInfos,
ISpincastJsonManagerConfig spincastJsonManagerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
Object
clone(Object originalObject)
Tries to clone an object to a IJsonObject or
a IJsonArray, if the object is not of
a primitive type (or BigDecimal).
Object
clone(Object originalObject,
boolean mutable)
Tries to clone an object to a IJsonObject or
a IJsonArray, if the object is not of
a primitive type (or BigDecimal).
IJsonArray
cloneJsonArray(IJsonArray jsonArray)
Deep copy of the IJsonArray, so any
modification to the original won't affect the
clone, and vice-versa.
IJsonArray
cloneJsonArray(IJsonArray jsonArray,
boolean mutable)
Deep copy of the IJsonArray, so any
modification to the original won't affect the
clone, and vice-versa.
IJsonObject
cloneJsonObject(IJsonObject jsonObject)
Deep copy of the IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.
IJsonObject
cloneJsonObject(IJsonObject jsonObject,
boolean mutable)
Deep copy of the IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.
protected void
configureEmptyBeans(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
protected void
configureMixins(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
protected void
configureObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Configuration of the ObjectMapper.
Object
convertToNativeType(Object originalObject)
Convert a random object to a valid native Json type, if
it's not already.
IJsonObject
create()
Creates an empty JsonObject
IJsonObject
create(InputStream inputStream)
Creates a JsonObject from an inputStream.
IJsonObject
create(Map<String,?> params)
Creates an empty JsonObject based on the specified Map.
IJsonObject
create(String jsonString)
Creates a JsonObject from a Json
String.
IJsonArray
createArray()
Creates an empty JsonArray.
IJsonArray
createArray(InputStream inputStream)
Creates a JsonArray from an inputStream.
IJsonArray
createArray(List<?> elements)
Creates a JsonArray from a List
of elements.
IJsonArray
createArray(String jsonString)
Creates a JsonArray from a Json
String.
IJsonArrayImmutable
createArrayImmutable(IJsonArray jsonArray)
Make a IJsonArray immutable, no element
could be added or removed on it.
IJsonObjectImmutable
createImmutable(IJsonObject jsonObject)
Make a IJsonObject immutable, no element
could be added or removed on it.
protected com.fasterxml.jackson.databind.ObjectMapper
createObjectManager()
Creates the ObjectMapper
<T> T
fromJsonInputStream(InputStream inputStream,
Class<T> clazz)
Creates an instance of the specified T type
from a Json inputStream.
Map<String,Object>
fromJsonInputStreamToMap(InputStream inputStream)
Creates a Map<String, Object> from a Json inputStream.
<T> T
fromJsonString(String jsonString,
Class<T> clazz)
Creates an instance of the specified T type
from a Json String.
Map<String,Object>
fromJsonStringToMap(String jsonString)
Creates a Map<String, Object> from a Json
String.
protected com.fasterxml.jackson.databind.JsonSerializer<Date>
getDateSerializer()
protected com.google.inject.Injector
getGuice()
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat
getIso8601DateParser1()
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat
getIso8601DateParser2()
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat
getIso8601DateParser3()
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat
getIso8601DateParserDefault()
protected com.fasterxml.jackson.core.util.DefaultPrettyPrinter
getJacksonPrettyPrinter()
protected String
getJacksonPrettyPrinterIndentation()
protected String
getJacksonPrettyPrinterNewline()
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonArray>
getJsonArrayDeserializer()
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonArray>
getJsonArraySerializer()
protected Set<IJsonMixinInfo>
getJsonMixinInfos()
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonObject>
getJsonObjectDeserializer()
protected IJsonObjectFactory
getJsonObjectFactory()
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonObject>
getJsonObjectSerializer()
protected com.fasterxml.jackson.databind.ObjectMapper
getObjectMapper()
protected ISpincastJsonManagerConfig
getSpincastJsonManagerConfig()
protected void
injectDependencies(Object obj)
Once the deserialization of an Object is done,
we inject dependencies using Guice.
Date
parseDateFromJson(String str)
Currently support ISO 8601 encoded dates.
protected void
registerCustomModules(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
protected void
registerDateModule(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Register our custom serializers for dates.
protected void
registerIJsonObjectModule(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Register our custom (de)serializers for IJsonObject
String
toJsonString(Object obj)
Gets the Json String representation of
the specified object.
String
toJsonString(Object obj,
boolean pretty)
Gets the Json String representation of the
specified object.
-
-
Constructor Detail
-
SpincastJsonManager
@Inject
public SpincastJsonManager(com.google.inject.Provider<com.google.inject.Injector> guiceProvider,
IJsonObjectFactory jsonObjectFactory,
@Nullable
Set<IJsonMixinInfo> jsonMixinInfos,
ISpincastJsonManagerConfig spincastJsonManagerConfig)
-
Method Detail
-
getGuice
protected com.google.inject.Injector getGuice()
-
getJsonObjectFactory
protected IJsonObjectFactory getJsonObjectFactory()
-
getJsonMixinInfos
protected Set<IJsonMixinInfo> getJsonMixinInfos()
-
getSpincastJsonManagerConfig
protected ISpincastJsonManagerConfig getSpincastJsonManagerConfig()
-
getJacksonPrettyPrinter
protected com.fasterxml.jackson.core.util.DefaultPrettyPrinter getJacksonPrettyPrinter()
-
getJacksonPrettyPrinterNewline
protected String getJacksonPrettyPrinterNewline()
-
getJacksonPrettyPrinterIndentation
protected String getJacksonPrettyPrinterIndentation()
-
getIso8601DateParserDefault
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat getIso8601DateParserDefault()
-
getIso8601DateParser1
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat getIso8601DateParser1()
-
getIso8601DateParser2
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat getIso8601DateParser2()
-
getIso8601DateParser3
protected org.spincast.shaded.org.apache.commons.lang3.time.FastDateFormat getIso8601DateParser3()
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
createObjectManager
protected com.fasterxml.jackson.databind.ObjectMapper createObjectManager()
Creates the ObjectMapper
-
configureObjectMapper
protected void configureObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Configuration of the ObjectMapper.
-
configureEmptyBeans
protected void configureEmptyBeans(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
configureMixins
protected void configureMixins(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
getJsonObjectSerializer
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonObject> getJsonObjectSerializer()
-
getJsonArraySerializer
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonArray> getJsonArraySerializer()
-
getDateSerializer
protected com.fasterxml.jackson.databind.JsonSerializer<Date> getDateSerializer()
-
getJsonObjectDeserializer
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonObject> getJsonObjectDeserializer()
-
getJsonArrayDeserializer
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonArray> getJsonArrayDeserializer()
-
registerCustomModules
protected void registerCustomModules(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
registerIJsonObjectModule
protected void registerIJsonObjectModule(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Register our custom (de)serializers for IJsonObject
-
registerDateModule
protected void registerDateModule(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Register our custom serializers for dates.
-
toJsonString
public String toJsonString(Object obj)
Description copied from interface: IJsonManager
Gets the Json String representation of
the specified object.
- Specified by:
toJsonString in interface IJsonManager
-
toJsonString
public String toJsonString(Object obj,
boolean pretty)
Description copied from interface: IJsonManager
Gets the Json String representation of the
specified object.
- Specified by:
toJsonString in interface IJsonManager
pretty - if true, the generated
String will be formatted.
-
injectDependencies
protected void injectDependencies(Object obj)
Once the deserialization of an Object is done,
we inject dependencies using Guice.
-
fromJsonString
public <T> T fromJsonString(String jsonString,
Class<T> clazz)
Description copied from interface: IJsonManager
Creates an instance of the specified T type
from a Json String.
- Specified by:
fromJsonString in interface IJsonManager
-
fromJsonInputStream
public <T> T fromJsonInputStream(InputStream inputStream,
Class<T> clazz)
Description copied from interface: IJsonManager
Creates an instance of the specified T type
from a Json inputStream.
- Specified by:
fromJsonInputStream in interface IJsonManager
-
fromJsonStringToMap
public Map<String,Object> fromJsonStringToMap(String jsonString)
Description copied from interface: IJsonManager
Creates a Map<String, Object> from a Json
String.
- Specified by:
fromJsonStringToMap in interface IJsonManager
-
fromJsonInputStreamToMap
public Map<String,Object> fromJsonInputStreamToMap(InputStream inputStream)
Description copied from interface: IJsonManager
Creates a Map<String, Object> from a Json inputStream.
- Specified by:
fromJsonInputStreamToMap in interface IJsonManager
-
create
public IJsonObject create()
Description copied from interface: IJsonManager
Creates an empty JsonObject
- Specified by:
create in interface IJsonManager
-
create
public IJsonObject create(String jsonString)
Description copied from interface: IJsonManager
Creates a JsonObject from a Json
String.
- Specified by:
create in interface IJsonManager
-
create
public IJsonObject create(Map<String,?> params)
Description copied from interface: IJsonManager
Creates an empty JsonObject based on the specified Map.
An attempt will be made to create a deep copy of every elements so
a modification won't affect any external referecen and vice-versa.
- Specified by:
create in interface IJsonManager
-
create
public IJsonObject create(InputStream inputStream)
Description copied from interface: IJsonManager
Creates a JsonObject from an inputStream.
- Specified by:
create in interface IJsonManager
-
createImmutable
public IJsonObjectImmutable createImmutable(IJsonObject jsonObject)
Description copied from interface: IJsonManager
Make a IJsonObject immutable, no element
could be added or removed on it.
- Specified by:
createImmutable in interface IJsonManager
-
createArray
public IJsonArray createArray()
Description copied from interface: IJsonManager
Creates an empty JsonArray.
- Specified by:
createArray in interface IJsonManager
-
createArray
public IJsonArray createArray(String jsonString)
Description copied from interface: IJsonManager
Creates a JsonArray from a Json
String.
- Specified by:
createArray in interface IJsonManager
-
createArray
public IJsonArray createArray(List<?> elements)
Description copied from interface: IJsonManager
Creates a JsonArray from a List
of elements.
- Specified by:
createArray in interface IJsonManager
-
createArray
public IJsonArray createArray(InputStream inputStream)
Description copied from interface: IJsonManager
Creates a JsonArray from an inputStream.
- Specified by:
createArray in interface IJsonManager
-
createArrayImmutable
public IJsonArrayImmutable createArrayImmutable(IJsonArray jsonArray)
Description copied from interface: IJsonManager
Make a IJsonArray immutable, no element
could be added or removed on it.
- Specified by:
createArrayImmutable in interface IJsonManager
-
parseDateFromJson
public Date parseDateFromJson(String str)
Currently support ISO 8601 encoded dates.
- Specified by:
parseDateFromJson in interface IJsonManager
-
cloneJsonObject
public IJsonObject cloneJsonObject(IJsonObject jsonObject)
Description copied from interface: IJsonManager
Deep copy of the IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.
The resulting IJsonObject is mutable.
- Specified by:
cloneJsonObject in interface IJsonManager
-
cloneJsonObject
public IJsonObject cloneJsonObject(IJsonObject jsonObject,
boolean mutable)
Description copied from interface: IJsonManager
Deep copy of the IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.
- Specified by:
cloneJsonObject in interface IJsonManager
mutable - if false, the resulting
IJsonArray and all its children
will be immutable.
-
cloneJsonArray
public IJsonArray cloneJsonArray(IJsonArray jsonArray)
Description copied from interface: IJsonManager
Deep copy of the IJsonArray, so any
modification to the original won't affect the
clone, and vice-versa.
The resulting IJsonArray is mutable.
- Specified by:
cloneJsonArray in interface IJsonManager
-
cloneJsonArray
public IJsonArray cloneJsonArray(IJsonArray jsonArray,
boolean mutable)
Description copied from interface: IJsonManager
Deep copy of the IJsonArray, so any
modification to the original won't affect the
clone, and vice-versa.
- Specified by:
cloneJsonArray in interface IJsonManager
mutable - if false, the resulting
IJsonArray and all its children
will be immutable.
-
convertToNativeType
public Object convertToNativeType(Object originalObject)
Description copied from interface: IJsonManager
Convert a random object to a valid native Json type, if
it's not already.
- Specified by:
convertToNativeType in interface IJsonManager
-
clone
public Object clone(Object originalObject)
Description copied from interface: IJsonManager
Tries to clone an object to a IJsonObject or
a IJsonArray, if the object is not of
a primitive type (or BigDecimal).
The cloning is made by serializing the Object to a
Json string, and deserializing back. So any (de)serialization
rules apply.
The non primitive object will be cloned to a IJsonArray
if it is a :
-
IJsonArray
-
Collection
-
Array
- Specified by:
clone in interface IJsonManager
-
clone
public Object clone(Object originalObject,
boolean mutable)
Description copied from interface: IJsonManager
Tries to clone an object to a IJsonObject or
a IJsonArray, if the object is not of
a primitive type (or BigDecimal).
The cloning is made by serializing the Object to a
Json string, and deserializing back. So any (de)serialization
rules apply.
The non primitive object will be cloned to a IJsonArray
if it is a :
-
IJsonArray
-
Collection
-
Array
- Specified by:
clone in interface IJsonManager
mutable - if false, the resulting
Object and all its potential children
will be immutable.
Copyright © 2016. All rights reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy