|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.kopitubruk.util.json.JSONConfig
public class JSONConfig
A configuration object for JSONUtil to control various encoding options.
It is possible to change the defaults by using the
JSONConfigDefaults class. See that class for details.
These are the names of the boolean flags and their normal defaults if you don't change them. See the setters for these for descriptions of what they do.
These could cause problems for some things that take JSON. Defaults are for standard JSON. Be careful about changing these. They should work fine if the JSON is interpreted by a standard Javascript eval(), except ECMAScript 6 code points if your interpreter doesn't support those. Going non-default on any of these tends not to work in strict JSON parsers such as JQuery.
You can change the locale being used for error messages and log messages and possibly by JSONAble objects for encoding.
You can create number formats associated with specific numeric types if you want your numbers encoded in a certain way.
If you've enabled special date handling options, you can change the way date strings are generated and the way that they are parsed.
This class also keeps track of classes which will be automatically reflected when encountered.
This class NOT thread safe. There are issues with the loop detection logic and any custom number or date formats used. Never share objects of this class between threads.
JSONConfigDefaults,
Serialized Form| Field Summary | |
|---|---|
static int |
DISCARD
Discard bad data. |
static int |
ESCAPE
Escape bad data. |
static int |
EXCEPTION
Throw an exception on bad data. |
static int |
PASS
Pass bad data through. |
static int |
REPLACE
Replace bad data with the Unicode replacement character U+FFFD. |
| Constructor Summary | |
|---|---|
JSONConfig()
Create a JSONConfig |
|
JSONConfig(Locale locale)
Create a JSONConfig with the given locale. |
|
| Method Summary | |
|---|---|
JSONConfig |
addDateParseFormat(DateFormat fmt)
Add a date parsing format to the list of parsing formats. |
DateFormat |
addDateParseFormat(String fmtStr)
Add a date parsing format to the list of parsing formats. |
JSONConfig |
addDateParseFormats(Collection<? extends DateFormat> fmts)
Add a collection of date parsing formats to the list of date parsing formats. |
JSONConfig |
addNumberFormat(Class<? extends Number> numericClass,
NumberFormat fmt)
Add a number format for a particular type that extends Number. |
JSONConfig |
addNumberFormat(Number numericType,
NumberFormat fmt)
Add a number format for a particular type that extends Number. |
JSONConfig |
addNumberFormats(Map<Class<? extends Number>,NumberFormat> numFmtMap)
Add a map of number formats to the current map of number formats. |
JSONConfig |
addReflectClass(Object obj)
Add the class of the given object to the set of classes that automatically get reflected. |
JSONConfig |
addReflectClassByName(String className)
Add the given class to the set of classes to be reflected. |
JSONConfig |
addReflectClasses(Collection<?> classes)
Add the classes of all of the given objests to the list of classes that automatically get reflected. |
JSONConfig |
clearDateGenFormat()
Clear date generation format. |
JSONConfig |
clearDateParseFormats()
Clear any date parse formats. |
JSONConfig |
clearNumberFormats()
Clear all number formats. |
JSONConfig |
clearReflectClasses()
Clear all reflection classes, disabling all automatic reflection. |
JSONConfig |
clone()
Return a clone of this object. |
IndentPadding |
getIndentPadding()
Get the padding object. |
Locale |
getLocale()
Get the locale for this instance. |
NumberFormat |
getNumberFormat(Class<? extends Number> numericClass)
Get the number format for the given class. |
NumberFormat |
getNumberFormat(Number num)
Get the number format for the class of the given numeric type. |
JSONReflectedClass |
getReflectedClass(Object obj)
Get the JSONReflectedClass for the given object if it is stored. |
int |
getReflectionPrivacy()
Get the reflection privacy level. |
int |
getUndefinedCodePointPolicy()
Get the policy for undefined code points. |
int |
getUnmatchedSurrogatePolicy()
Get the policy for unmatched surrogates. |
boolean |
isAllowReservedWordsInIdentifiers()
Get the allowReservedWordsInIdentifiers policy. |
boolean |
isCacheReflectionData()
Get the the cacheReflectionData policy. |
boolean |
isDetectDataStructureLoops()
Return true if data structure loops will be detected. |
boolean |
isEncodeDatesAsObjects()
Get the encode dates policy. |
boolean |
isEncodeDatesAsStrings()
Get the encode dates as strings policy. |
boolean |
isEncodeNumericStringsAsNumbers()
If true, then strings will be checked for number patterns and if they look like numbers, then they won't be quoted. |
boolean |
isEscapeBadIdentifierCodePoints()
Find out if bad identifier code points will be escaped. |
boolean |
isEscapeNonAscii()
Check if non-ascii characters are to be encoded as Unicode escapes. |
boolean |
isEscapeSurrogates()
Return the escape surrogates policy. |
boolean |
isFastStrings()
Get the fastStrings policy. |
boolean |
isFormatDates()
Find out if special date formatting is enabled. |
boolean |
isFullJSONIdentifierCodePoints()
Get the full JSON identifier code points policy. |
boolean |
isPassThroughEscapes()
Get the pass through escapes policy. |
boolean |
isPreciseNumbers()
Get the preciseNumbers policy. |
boolean |
isQuoteIdentifier()
Find out what the identifier quote policy is. |
boolean |
isReflectClass(Object obj)
Return true if the given class is in the set of classes being automatically reflected. |
boolean |
isReflectUnknownObjects()
Get the reflection of unknown objects policy. |
boolean |
isSmallNumbers()
Get the smallNumbers policy. |
boolean |
isUnEscapeWherePossible()
The unEscape policy. |
boolean |
isUseECMA6()
Find out if ECMAScript 6 code point escapes are enabled. |
boolean |
isUsePrimitiveArrays()
The primitive arrays policy. |
boolean |
isValidatePropertyNames()
Check if property names will be validated. |
JSONConfig |
removeNumberFormat(Class<? extends Number> numericClass)
Remove the requested class from the number formats that this config knows about. |
JSONConfig |
removeNumberFormat(Number num)
Remove the requested class from the number formats that this config knows about. |
JSONConfig |
removeReflectClass(Object obj)
Remove the given class from the list of automatically reflected classes. |
JSONConfig |
removeReflectClasses(Collection<?> classes)
Remove the given classes from the list of automatically reflected classes. |
JSONConfig |
setAllowReservedWordsInIdentifiers(boolean allowReservedWordsInIdentifiers)
If true then reserved words will be allowed in identifiers even when identifier validation is enabled. |
JSONConfig |
setBadCharacterPolicy(int badCharacterPolicy)
Convenience method to call both setUnmatchedSurrogatePolicy(int)
and setUndefinedCodePointPolicy(int) using the same value. |
JSONConfig |
setCacheReflectionData(boolean cacheReflectionData)
If true, then when an object is reflected its reflection data will be cached to improve performance on subsequent reflections of objects of its class. |
JSONConfig |
setDateGenFormat(DateFormat fmt)
Set the date string generation format used when encodeDatesAsStrings or encodeDatesAsObjects are true. |
DateFormat |
setDateGenFormat(String fmtStr)
Set the date string generation format. |
JSONConfig |
setDetectDataStructureLoops(boolean detectDataStructureLoops)
Enable or disable data structure loop detection. |
JSONConfig |
setEncodeDatesAsObjects(boolean encodeDatesAsObjects)
If true, then Date objects will be encoded as
Javascript dates, using new Date(dateString). |
JSONConfig |
setEncodeDatesAsStrings(boolean encodeDatesAsStrings)
If true, then Date objects will be encoded as ISO 8601 date
strings or a custom date format if you have called
setDateGenFormat(DateFormat). |
JSONConfig |
setEncodeNumericStringsAsNumbers(boolean encodeNumericStringsAsNumbers)
If true, then strings will be checked for number patterns and if they look like numbers, then they won't be quoted. |
JSONConfig |
setEscapeBadIdentifierCodePoints(boolean escapeBadIdentifierCodePoints)
If true, then any bad code points in identifiers will be escaped. |
JSONConfig |
setEscapeNonAscii(boolean escapeNonAscii)
If you want non-ascii characters encoded as Unicode escapes in strings and identifiers, you can do that by setting this to true. |
JSONConfig |
setEscapeSurrogates(boolean escapeSurrogates)
If true then all surrogates will be escaped in strings and identifiers and escapeNonAscii will be forced to false. |
JSONConfig |
setFastStrings(boolean fastStrings)
If true, then string values will be copied to the output with no escaping or validation. |
JSONConfig |
setFullJSONIdentifierCodePoints(boolean fullJSONIdentifierCodePoints)
If true, then the full set of identifier code points permitted by the JSON standard will be allowed instead of the more restrictive set permitted by the ECMAScript standard. |
JSONConfig |
setIndentPadding(IndentPadding indentPadding)
Set the padding object. |
JSONConfig |
setLocale(Locale locale)
Set the locale. |
JSONConfig |
setPassThroughEscapes(boolean passThroughEscapes)
If true, then legal escapes in strings will be passed through unchanged. |
JSONConfig |
setPreciseNumbers(boolean preciseNumbers)
If true then integer numbers which are not exactly representable by a 64 bit double precision floating point number will be quoted in the output. |
JSONConfig |
setQuoteIdentifier(boolean quoteIdentifier)
Control whether identifiers are quoted or not. |
JSONConfig |
setReflectionPrivacy(int reflectionPrivacy)
Set the privacy level for reflection. |
JSONConfig |
setReflectUnknownObjects(boolean reflectUnknownObjects)
Set the unknown object reflection encoding policy. |
JSONConfig |
setSmallNumbers(boolean smallNumbers)
If true then JSONParser will attempt to minimize the
storage used for all numbers. |
JSONConfig |
setUndefinedCodePointPolicy(int undefinedCodePointPolicy)
Tell JSONUtil what to do when it encounters undefined code points in strings and identifiers. |
JSONConfig |
setUnEscapeWherePossible(boolean unEscapeWherePossible)
If true then where possible, undo inline escapes in strings before going through normal string processing. |
JSONConfig |
setUnmatchedSurrogatePolicy(int unmatchedSurrogatePolicy)
Tell JSONUtil what to do when it encounters unmatched surrogates in strings and identifiers. |
JSONConfig |
setUseECMA6(boolean useECMA6)
If you set this to true, then when JSONUtil generates Unicode escapes, it will use ECMAScript 6 code point escapes if they are shorter than code unit escapes. |
JSONConfig |
setUsePrimitiveArrays(boolean usePrimitiveArrays)
If true, then when JSONParser encounters a JSON array of non-null
wrappers of primitives and those primitives are all compatible with each
other, then instead of an ArrayList of wrappers for those
primitives it will create an array of those primitives in order to save
memory. |
JSONConfig |
setValidatePropertyNames(boolean validatePropertyNames)
If true, then property names will be validated. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int REPLACE
setUnmatchedSurrogatePolicy(int),
setUndefinedCodePointPolicy(int),
setBadCharacterPolicy(int),
JSONConfigDefaults.setUnmatchedSurrogatePolicy(int),
JSONConfigDefaults.setUndefinedCodePointPolicy(int),
JSONConfigDefaults.setBadCharacterPolicy(int),
Constant Field Valuespublic static final int DISCARD
setUnmatchedSurrogatePolicy(int),
setUndefinedCodePointPolicy(int),
setBadCharacterPolicy(int),
JSONConfigDefaults.setUnmatchedSurrogatePolicy(int),
JSONConfigDefaults.setUndefinedCodePointPolicy(int),
JSONConfigDefaults.setBadCharacterPolicy(int),
Constant Field Valuespublic static final int EXCEPTION
setUnmatchedSurrogatePolicy(int),
setUndefinedCodePointPolicy(int),
setBadCharacterPolicy(int),
JSONConfigDefaults.setUnmatchedSurrogatePolicy(int),
JSONConfigDefaults.setUndefinedCodePointPolicy(int),
JSONConfigDefaults.setBadCharacterPolicy(int),
Constant Field Valuespublic static final int ESCAPE
setUnmatchedSurrogatePolicy(int),
setUndefinedCodePointPolicy(int),
setBadCharacterPolicy(int),
JSONConfigDefaults.setUnmatchedSurrogatePolicy(int),
JSONConfigDefaults.setUndefinedCodePointPolicy(int),
JSONConfigDefaults.setBadCharacterPolicy(int),
Constant Field Valuespublic static final int PASS
setUnmatchedSurrogatePolicy(int),
setUndefinedCodePointPolicy(int),
setBadCharacterPolicy(int),
JSONConfigDefaults.setUnmatchedSurrogatePolicy(int),
JSONConfigDefaults.setUndefinedCodePointPolicy(int),
JSONConfigDefaults.setBadCharacterPolicy(int),
Constant Field Values| Constructor Detail |
|---|
public JSONConfig()
public JSONConfig(Locale locale)
locale - the locale to set.| Method Detail |
|---|
public JSONConfig clone()
clone in class Objectpublic Locale getLocale()
JSONConfigDefaults.getLocale()public JSONConfig setLocale(Locale locale)
JSONAble's
that can use a locale.
locale - the locale to set
JSONConfigDefaults.setLocale(Locale)public NumberFormat getNumberFormat(Class<? extends Number> numericClass)
numericClass - A class.
JSONConfigDefaults.getNumberFormat(Class)public NumberFormat getNumberFormat(Number num)
num - An object that implements Number.
JSONConfigDefaults.getNumberFormat(Number)
public JSONConfig addNumberFormat(Class<? extends Number> numericClass,
NumberFormat fmt)
This could allow you to limit the number of digits printed for a float or a double for example, getting rid of excess digits caused by rounding problems in floating point numbers.
numericClass - The class.fmt - The number format.
JSONConfigDefaults.addNumberFormat(Class, NumberFormat)
public JSONConfig addNumberFormat(Number numericType,
NumberFormat fmt)
This could allow you to limit the number of digits printed for a float or a double for example, getting rid of excess digits caused by rounding problems in floating point numbers.
numericType - The object.fmt - The number format.
JSONConfigDefaults.addNumberFormat(Number, NumberFormat)public JSONConfig addNumberFormats(Map<Class<? extends Number>,NumberFormat> numFmtMap)
numFmtMap - The input map.
JSONConfigDefaults.addNumberFormats(Map)public JSONConfig removeNumberFormat(Class<? extends Number> numericClass)
numericClass - The class.
JSONConfigDefaults.removeNumberFormat(Class)public JSONConfig removeNumberFormat(Number num)
num - An object that implements Number.
JSONConfigDefaults.removeNumberFormat(Number)public JSONConfig clearNumberFormats()
JSONConfigDefaults.clearNumberFormats()public JSONConfig setDateGenFormat(DateFormat fmt)
fmt - the dateFormat to set
JSONConfigDefaults.setDateGenFormat(DateFormat)public DateFormat setDateGenFormat(String fmtStr)
fmtStr - passed to the constructor
SimpleDateFormat.SimpleDateFormat(String,Locale)
using the locale from this config object.
JSONConfigDefaults.setDateGenFormat(String)public JSONConfig clearDateGenFormat()
JSONConfigDefaults.clearDateGenFormat()public JSONConfig addDateParseFormat(DateFormat fmt)
fmt - A date parsing format.
JSONConfigDefaults.addDateParseFormat(DateFormat)public DateFormat addDateParseFormat(String fmtStr)
fmtStr - Passed to SimpleDateFormat.SimpleDateFormat(String,Locale)
using the locale from this config object to create a DateFormat.
JSONConfigDefaults.addDateParseFormat(String)public JSONConfig addDateParseFormats(Collection<? extends DateFormat> fmts)
fmts - A collection of date parsing formats.
JSONConfigDefaults.addDateParseFormats(Collection)public JSONConfig clearDateParseFormats()
JSONConfigDefaults.clearDateParseFormats()public IndentPadding getIndentPadding()
JSONConfigDefaults.getIndentPadding()public JSONConfig setIndentPadding(IndentPadding indentPadding)
indentPadding - the padding object.
JSONConfigDefaults.setIndentPadding(IndentPadding)public int getReflectionPrivacy()
ReflectUtil.PRIVATE,
ReflectUtil.PACKAGE,
ReflectUtil.PROTECTED,
ReflectUtil.PUBLIC,
JSONConfigDefaults.getReflectionPrivacy()public JSONConfig setReflectionPrivacy(int reflectionPrivacy)
ReflectUtil.PUBLIC.
reflectionPrivacy - the level to set
ReflectUtil.PRIVATE,
ReflectUtil.PACKAGE,
ReflectUtil.PROTECTED,
ReflectUtil.PUBLIC,
JSONConfigDefaults.setReflectionPrivacy(int)public boolean isReflectClass(Object obj)
obj - An object to check
JSONConfigDefaults.isReflectClass(Object)public JSONReflectedClass getReflectedClass(Object obj)
JSONReflectedClass for the given object if it is stored.
The main reason that you might want to use this is to modify the fields
or aliases that are reflected in the class.
obj - the class being reflected.
JSONConfigDefaults.getReflectedClass(Object)public JSONConfig addReflectClass(Object obj)
Iterable
or Enumeration, then all objects in it will be added.
obj - The object whose class to add to the reflect list.
JSONReflectedClass,
addReflectClasses(Collection),
addReflectClassByName(String),
setReflectUnknownObjects(boolean),
JSONConfigDefaults.addReflectClass(Object)
public JSONConfig addReflectClassByName(String className)
throws ClassNotFoundException
If you wish to use reflection with fields, you can append the field names to the class name, separated by commas before each field name. Field names which do not look like valid Java identifier names will be silently discarded. For example, if you want to reflect a class called "org.example.Widget" and it has fields called "a", "b" and "c" but you only want "a" and "c", then you can pass "org.example.Widget,a,c" to this method.
If you wish to use custom field names with reflection you can use name=alias pairs separated by commas as with the field names. For example, if you want to reflect a class called "org.example.Widget" and it has a field called "foo" but you want that field encoded as "bar" you can pass "org.example.Widget,foo=bar" to this method.
className - The name of the class suitable for
ClassLoader.loadClass(String) followed optionally by a
comma separated list of field names and/or field aliases.
ClassNotFoundException - If the class cannot be loaded.addReflectClass(Object),
addReflectClasses(Collection),
setReflectUnknownObjects(boolean),
JSONConfigDefaults.addReflectClassByName(String)public JSONConfig addReflectClasses(Collection<?> classes)
classes - The objects to reflect.
JSONReflectedClass,
addReflectClass(Object),
addReflectClassByName(String),
setReflectUnknownObjects(boolean),
JSONConfigDefaults.addReflectClasses(Collection)public JSONConfig removeReflectClass(Object obj)
Iterable or Enumeration,
then all objects in it will be removed.
obj - An object of the type to be removed from the reflect list.
JSONConfigDefaults.removeReflectClass(Object)public JSONConfig removeReflectClasses(Collection<?> classes)
classes - A collection objects of the types to be removed from
the reflect list.
JSONConfigDefaults.removeReflectClasses(Collection)public JSONConfig clearReflectClasses()
JSONConfigDefaults.clearReflectClasses()public int getUnmatchedSurrogatePolicy()
REPLACE,
DISCARD,
EXCEPTION,
ESCAPE,
PASS,
JSONConfigDefaults.getUnmatchedSurrogatePolicy()public JSONConfig setUnmatchedSurrogatePolicy(int unmatchedSurrogatePolicy)
REPLACE - Replace with the Unicode replacement character U+FFFD (default)DISCARD - Discard them.EXCEPTION - Throw an UnmatchedSurrogateExceptionESCAPE - Include them but escape themPASS - Pass them through unmodified.
unmatchedSurrogatePolicy - the unmatchedSurrogatePolicy to set
JSONConfigDefaults.setUnmatchedSurrogatePolicy(int)public int getUndefinedCodePointPolicy()
REPLACE,
DISCARD,
EXCEPTION,
ESCAPE,
PASS,
JSONConfigDefaults.getUndefinedCodePointPolicy()public JSONConfig setUndefinedCodePointPolicy(int undefinedCodePointPolicy)
REPLACE - Replace with the Unicode replacement character U+FFFD (default)DISCARD - Discard them.EXCEPTION - Throw an UndefinedCodePointExceptionESCAPE - Include them but escape themPASS - Pass them through unmodified.
In code that interprets inline escapes, when an undefined code point is
specified by an ECMAScript 6 code point escape and that value is greater
than the maximum permissible code point (U+10FFFF), then for ESCAPE
or PASS the code point will be set to the Unicode replacement
character U+FFFD to indicate that the character has been replaced.
undefinedCodePointPolicy - the undefinedCodePointPolicy to set
JSONConfigDefaults.setUndefinedCodePointPolicy(int)public JSONConfig setBadCharacterPolicy(int badCharacterPolicy)
setUnmatchedSurrogatePolicy(int)
and setUndefinedCodePointPolicy(int) using the same value.
badCharacterPolicy - the badCharacterPolicy to set
REPLACE,
DISCARD,
EXCEPTION,
ESCAPE,
PASS,
JSONConfigDefaults.setBadCharacterPolicy(int)public boolean isValidatePropertyNames()
JSONConfigDefaults.isValidatePropertyNames()public JSONConfig setValidatePropertyNames(boolean validatePropertyNames)
When validation is enabled and fullJSONIdentifierCodePoints is false, then only code points which are allowed in identifiers will be permitted as per the ECMAScript 5 or 6 standard as well as disallowing reserved words as per the JSON spec. If fullJSONIdentifierCodePoints is true, then all code points permitted by the ECMA JSON standard will be permitted, though many of those are not permitted by the ECMAScript standard and will break if evaluated by a Javascript eval().
It will also check for duplicate property names in the same object, which is possible because keys in maps are not required to be String objects and it's possible (though not likely) for two objects which are not equal to have the same result from a toString() method.
validatePropertyNames - Set to false to disable property name validation.
JSONConfigDefaults.setValidatePropertyNames(boolean)public boolean isDetectDataStructureLoops()
JSONConfigDefaults.isDetectDataStructureLoops()public JSONConfig setDetectDataStructureLoops(boolean detectDataStructureLoops)
detectDataStructureLoops - If true then JSONUtil will attempt to detect loops in data structures.
JSONConfigDefaults.setDetectDataStructureLoops(boolean)public boolean isEscapeBadIdentifierCodePoints()
JSONConfigDefaults.isEscapeBadIdentifierCodePoints()public JSONConfig setEscapeBadIdentifierCodePoints(boolean escapeBadIdentifierCodePoints)
escapeBadIdentifierCodePoints - the escapeBadIdentifierCodePoints to set
JSONConfigDefaults.setEscapeBadIdentifierCodePoints(boolean)public boolean isFullJSONIdentifierCodePoints()
JSONConfigDefaults.isFullJSONIdentifierCodePoints()public JSONConfig setFullJSONIdentifierCodePoints(boolean fullJSONIdentifierCodePoints)
fullJSONIdentifierCodePoints - If true, then allow all code points permitted by the JSON standard in identifiers.
JSONConfigDefaults.setFullJSONIdentifierCodePoints(boolean)public boolean isFastStrings()
JSONConfigDefaults.isFastStrings()public JSONConfig setFastStrings(boolean fastStrings)
Only use this if you know that you have no unescaped characters in the range U+0000-U+001F or unescaped backslash or forward slash or double quote in your strings. If you want your JSON to be parsable by Javascript eval() then you also need to make sure that you don't have U+2028 (line separator) or U+2029 (paragraph separator).
That said, if you are encoding a lot of large strings, this can improve performance by eliminating the check for characters that need to be escaped.
fastStrings - If true, then string values will be copied as is with
no escaping or validation.
JSONConfigDefaults.setFastStrings(boolean)public boolean isEncodeNumericStringsAsNumbers()
JSONConfigDefaults.isEncodeNumericStringsAsNumbers()public JSONConfig setEncodeNumericStringsAsNumbers(boolean encodeNumericStringsAsNumbers)
JSONParser,
strings will examined and if they look like numbers, then they will be
parsed as numbers in the output. Default is false.
encodeNumericStringsAsNumbers - the encodeNumericStringsAsNumbers to set
JSONConfigDefaults.setEncodeNumericStringsAsNumbers(boolean)public boolean isEscapeNonAscii()
JSONConfigDefaults.isEscapeNonAscii()public JSONConfig setEscapeNonAscii(boolean escapeNonAscii)
escapeNonAscii - set to true if you want non-ascii to be Unicode escaped.
JSONConfigDefaults.setEscapeNonAscii(boolean)public boolean isEscapeSurrogates()
JSONConfigDefaults.isEscapeSurrogates()public JSONConfig setEscapeSurrogates(boolean escapeSurrogates)
escapeSurrogates - the escapeSurrogates to set
JSONConfigDefaults.setEscapeSurrogates(boolean)public boolean isUnEscapeWherePossible()
JSONConfigDefaults.isUnEscapeWherePossible()public JSONConfig setUnEscapeWherePossible(boolean unEscapeWherePossible)
isPassThroughEscapes() is set to
true. If true, then all recognized inline escapes are unescaped before
the string goes through normal processing. Note that this has no effect
if isFastStrings() returns true. This option can be useful if
you have strings with some of the Javascript escapes which are illegal in
JSON.
Note that this does not apply to property names. It is only applied to string values.
unEscapeWherePossible - If true then where possible, undo inline
escapes in strings.
JSONConfigDefaults.setUnEscapeWherePossible(boolean)public boolean isPassThroughEscapes()
JSONConfigDefaults.isPassThroughEscapes()public JSONConfig setPassThroughEscapes(boolean passThroughEscapes)
passThroughEscapes - If true, then pass escapes through.
JSONConfigDefaults.setPassThroughEscapes(boolean)public boolean isEncodeDatesAsStrings()
JSONConfigDefaults.isEncodeDatesAsStrings()public JSONConfig setEncodeDatesAsStrings(boolean encodeDatesAsStrings)
Date objects will be encoded as ISO 8601 date
strings or a custom date format if you have called
setDateGenFormat(DateFormat). If you set this to true, then
encodeDatesAsObjects will be set to false.
encodeDatesAsStrings - the encodeDatesAsStrings to set
JSONConfigDefaults.setEncodeDatesAsStrings(boolean)public boolean isReflectUnknownObjects()
JSONConfigDefaults.isReflectUnknownObjects()public JSONConfig setReflectUnknownObjects(boolean reflectUnknownObjects)
reflectUnknownObjects - If true, then attempt to use reflection to
encode objects which are otherwise unknown.
addReflectClass(Object),
addReflectClasses(Collection),
addReflectClassByName(String),
JSONConfigDefaults.setReflectUnknownObjects(boolean)public boolean isPreciseNumbers()
JSONConfigDefaults.isPreciseNumbers()public JSONConfig setPreciseNumbers(boolean preciseNumbers)
preciseNumbers - If true then quote integer numbers that lose precision in 64-bit floating point.
JSONConfigDefaults.setPreciseNumbers(boolean)public boolean isSmallNumbers()
JSONConfigDefaults.isSmallNumbers()public JSONConfig setSmallNumbers(boolean smallNumbers)
JSONParser will attempt to minimize the
storage used for all numbers. Decimal numbers will be reduced
to floats instead of doubles if it can done without losing
precision. Integer numbers will be reduced from long to int
or short or byte if they fit.
smallNumbers - If true then numbers will be made to use as little memory as possible.
JSONConfigDefaults.setSmallNumbers(boolean)public boolean isUsePrimitiveArrays()
JSONConfigDefaults.isUsePrimitiveArrays()public JSONConfig setUsePrimitiveArrays(boolean usePrimitiveArrays)
JSONParser encounters a JSON array of non-null
wrappers of primitives and those primitives are all compatible with each
other, then instead of an ArrayList of wrappers for those
primitives it will create an array of those primitives in order to save
memory.
This works for booleans and numbers. It will also convert an array of single character strings into an array of chars. Arrays of numbers will attempt to use the least complex type that does not lose information. You could easily end up with an array of bytes if all of your numbers are integers in the range -128 to 127. This option is meant to save as much memory as possible.
usePrimitiveArrays - if true, then the parser will create arrays of
primitives as applicable.
JSONConfigDefaults.setUsePrimitiveArrays(boolean)public boolean isCacheReflectionData()
JSONConfigDefaults.isCacheReflectionData()public JSONConfig setCacheReflectionData(boolean cacheReflectionData)
cacheReflectionData - if true, then cache reflection data.
JSONConfigDefaults.setCacheReflectionData(boolean)public boolean isQuoteIdentifier()
JSONConfigDefaults.isQuoteIdentifier()public JSONConfig setQuoteIdentifier(boolean quoteIdentifier)
quoteIdentifier - If true, then all identifiers will be quoted. If
false, then only those that really need quotes will be quoted.
JSONConfigDefaults.setQuoteIdentifier(boolean)public boolean isUseECMA6()
JSONConfigDefaults.isUseECMA6()public JSONConfig setUseECMA6(boolean useECMA6)
useECMA6 - If true, use EMCAScript 6 code point escapes and allow
ECMAScript 6 identifier character set.
JSONConfigDefaults.setUseECMA6(boolean)public boolean isAllowReservedWordsInIdentifiers()
JSONConfigDefaults.isAllowReservedWordsInIdentifiers()public JSONConfig setAllowReservedWordsInIdentifiers(boolean allowReservedWordsInIdentifiers)
allowReservedWordsInIdentifiers - the allowReservedWordsInIdentifiers to set
JSONConfigDefaults.setAllowReservedWordsInIdentifiers(boolean)public boolean isEncodeDatesAsObjects()
JSONConfigDefaults.isEncodeDatesAsObjects()public JSONConfig setEncodeDatesAsObjects(boolean encodeDatesAsObjects)
Date objects will be encoded as
Javascript dates, using new Date(dateString). If you
set this to true, then encodeDatesAsStrings will be
set to false.
encodeDatesAsObjects - the encodeDates to set
JSONConfigDefaults.setEncodeDatesAsObjects(boolean)public boolean isFormatDates()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||