TContext - DslJson contextpublic static class DslJson.Settings<TContext> extends Object
| Constructor and Description |
|---|
Settings() |
| Modifier and Type | Method and Description |
|---|---|
DslJson.Settings<TContext> |
allowArrayFormat(boolean allowArrayFormat)
Some encoders/decoders support writing objects in array format.
|
DslJson.Settings<TContext> |
creatorMarker(Class<? extends Annotation> marker,
boolean expandVisibility)
When there are multiple constructors, pick the one marked with annotation.
|
DslJson.Settings<TContext> |
doublePrecision(JsonReader.DoublePrecision precision)
By default doubles are not deserialized into an exact value in some rare edge cases.
|
DslJson.Settings<TContext> |
errorInfo(JsonReader.ErrorInfo errorInfo)
By default doubles are not deserialized into an exact value in some rare edge cases.
|
DslJson.Settings<TContext> |
fallbackTo(DslJson.Fallback<TContext> fallback)
Deprecated.
|
DslJson.Settings<TContext> |
includeServiceLoader()
Load converters using thread local ClassLoader.
|
DslJson.Settings<TContext> |
includeServiceLoader(ClassLoader loader)
Load converters using provided `ClassLoader` instance
Will scan through `META-INF/services/com.dslplatform.json.Configuration` file and register implementation during startup.
|
DslJson.Settings<TContext> |
limitDigitsBuffer(int size)
Specify maximum allowed size for digits buffer.
|
DslJson.Settings<TContext> |
limitStringBuffer(int size)
Specify maximum allowed size for string buffer.
|
DslJson.Settings<TContext> |
resolveBinder(DslJson.ConverterFactory<? extends JsonReader.BindObject> binder)
DslJson will iterate over converter factories when requested type is unknown.
|
DslJson.Settings<TContext> |
resolveReader(DslJson.ConverterFactory<? extends JsonReader.ReadObject> reader)
DslJson will iterate over converter factories when requested type is unknown.
|
DslJson.Settings<TContext> |
resolveWriter(DslJson.ConverterFactory<? extends JsonWriter.WriteObject> writer)
DslJson will iterate over converter factories when requested type is unknown.
|
DslJson.Settings<TContext> |
skipDefaultValues(boolean omitDefaults)
DslJson can exclude some properties from resulting JSON which it can reconstruct fully from schema information.
|
DslJson.Settings<TContext> |
unknownNumbers(JsonReader.UnknownNumberParsing unknownNumbers)
When processing JSON without a schema numbers can be deserialized in various ways:
- as longs and decimals
- as longs and doubles
- as decimals only
- as doubles only
Default is as long and BigDecimal
|
DslJson.Settings<TContext> |
useKeyCache(StringCache keyCache)
Use specific key cache implementation.
|
DslJson.Settings<TContext> |
useStringValuesCache(StringCache valuesCache)
Use specific string values cache implementation.
|
DslJson.Settings<TContext> |
with(Configuration conf)
Configure DslJson with custom Configuration during startup.
|
DslJson.Settings<TContext> |
withContext(TContext context)
Pass in context for DslJson.
|
DslJson.Settings<TContext> |
withJavaConverters(boolean javaSpecifics)
Enable converters for Java specific types (Graphics API) not available on Android.
|
public DslJson.Settings<TContext> withContext(@Nullable TContext context)
context - context propagated to JsonReaderspublic DslJson.Settings<TContext> withJavaConverters(boolean javaSpecifics)
javaSpecifics - should register Java specific converters@Deprecated public DslJson.Settings<TContext> fallbackTo(@Nullable DslJson.Fallback<TContext> fallback)
fallback - how to handle unsupported typepublic DslJson.Settings<TContext> skipDefaultValues(boolean omitDefaults)
omitDefaults - should exclude default values from resulting JSONpublic DslJson.Settings<TContext> allowArrayFormat(boolean allowArrayFormat)
allowArrayFormat - allow serialization via array formatpublic DslJson.Settings<TContext> useKeyCache(@Nullable StringCache keyCache)
To disable key cache, provide null for it.
keyCache - which key cache to usepublic DslJson.Settings<TContext> useStringValuesCache(@Nullable StringCache valuesCache)
To support memory restricted scenarios where there is limited number of string values, values cache can be used.
Not every "JSON string" will use this cache... eg UUID, LocalDate don't create an instance of string and therefore don't use this cache.
valuesCache - which values cache to usepublic DslJson.Settings<TContext> resolveWriter(DslJson.ConverterFactory<? extends JsonWriter.WriteObject> writer)
writer - registered writer factorypublic DslJson.Settings<TContext> resolveReader(DslJson.ConverterFactory<? extends JsonReader.ReadObject> reader)
reader - registered reader factorypublic DslJson.Settings<TContext> resolveBinder(DslJson.ConverterFactory<? extends JsonReader.BindObject> binder)
binder - registered binder factorypublic DslJson.Settings<TContext> includeServiceLoader()
Note that gradle on Android has issues with preserving that file, in which case it can be provided manually. DslJson will fall back to "expected" class name if it doesn't find anything during scanning.
public DslJson.Settings<TContext> includeServiceLoader(ClassLoader loader)
Note that gradle on Android has issues with preserving that file, in which case it can be provided manually. DslJson will fall back to "expected" class name if it doesn't find anything during scanning.
loader - ClassLoader to usepublic DslJson.Settings<TContext> errorInfo(JsonReader.ErrorInfo errorInfo)
errorInfo - information about error in parsing exceptionpublic DslJson.Settings<TContext> doublePrecision(JsonReader.DoublePrecision precision)
precision - type of double deserializationpublic DslJson.Settings<TContext> unknownNumbers(JsonReader.UnknownNumberParsing unknownNumbers)
unknownNumbers - how to deserialize numbers without a schemapublic DslJson.Settings<TContext> limitDigitsBuffer(int size)
size - maximum allowed size for digit bufferpublic DslJson.Settings<TContext> limitStringBuffer(int size)
size - maximum size of buffer in bytespublic DslJson.Settings<TContext> creatorMarker(Class<? extends Annotation> marker, boolean expandVisibility)
marker - annotation used for marking constructor or static method factoryexpandVisibility - should consider annotation declared on non public accessorpublic DslJson.Settings<TContext> with(Configuration conf)
conf - custom extensibility pointCopyright © 2023. All rights reserved.