- java.lang.Object
-
- at.syntaxerror.json5.JSONOptions
-
public class JSONOptions extends Object
This class used is used to customize the behaviour ofparsingandstringifying- Since:
- 1.1.0
- Author:
- SyntaxError404
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJSONOptions.DuplicateBehaviorAn enum containing all supported behaviors for duplicate keysstatic classJSONOptions.JSONOptionsBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JSONOptions.JSONOptionsBuilderbuilder()static @NonNull JSONOptionsgetDefaultOptions()Returns the default options for parsing and stringifyingJSONOptions.DuplicateBehaviorgetDuplicateBehaviour()Specifies the behavior when the same key is encountered multiple times within the sameJSONObjectbooleanisAllowBinaryLiterals()Whether binary literals (0b10101...) should be allowedbooleanisAllowCDigitSeparators()Whether C-style digit separators (123'456) should be allowedbooleanisAllowHexFloatingLiterals()Whether hexadecimal floating-point literals (e.g.booleanisAllowInfinity()WhetherInfinityshould be allowed as a number.booleanisAllowInvalidSurrogates()Whether invalid unicode surrogate pairs should be allowedbooleanisAllowJavaDigitSeparators()Whether Java-style digit separators (123_456) should be allowedbooleanisAllowLongUnicodeEscapes()Whether 32-bit unicode escape sequences (\U00123456) should be allowedbooleanisAllowNaN()WhetherNaNshould be allowed as a numberbooleanisAllowOctalLiterals()Whether octal literals (0o567...) should be allowedbooleanisQuoteSingle()Whether strings should be single-quoted (') instead of double-quoted (").booleanisStringifyAscii()Whether stringifying should only yield ASCII strings.booleanisStringifyUnixInstants()Whether instants should be stringifyed as unix timestamps.static voidsetDefaultOptions(@NonNull JSONOptions defaultOptions)Sets the default options for parsing and stringifying.JSONOptions.JSONOptionsBuildertoBuilder()
-
-
-
Method Detail
-
builder
public static JSONOptions.JSONOptionsBuilder builder()
-
toBuilder
public JSONOptions.JSONOptionsBuilder toBuilder()
-
isStringifyUnixInstants
public boolean isStringifyUnixInstants()
Whether instants should be stringifyed as unix timestamps. If this isfalse, instants will be stringifyed as strings (according to RFC 3339, Section 5.6).Default:
falseThis is a
Stringify-only option- Returns:
- whether instants should be stringifyed as unix timestamps
- Since:
- 1.1.0
-
isStringifyAscii
public boolean isStringifyAscii()
Whether stringifying should only yield ASCII strings. All non-ASCII characters will be converted to their Unicode escape sequence (\uXXXX).Default:
falseThis is a
Stringify-only option- Returns:
- whether stringifying should only yield ASCII strings
- Since:
- 2.0.0
-
isAllowNaN
public boolean isAllowNaN()
WhetherNaNshould be allowed as a numberDefault:
true- Returns:
- whether
NaNshould be allowed - Since:
- 1.1.0
-
isAllowInfinity
public boolean isAllowInfinity()
WhetherInfinityshould be allowed as a number. This applies to both+Infinityand-InfinityDefault:
true- Returns:
- whether
Infinityshould be allowed - Since:
- 1.1.0
-
isAllowInvalidSurrogates
public boolean isAllowInvalidSurrogates()
Whether invalid unicode surrogate pairs should be allowedDefault:
trueThis is a
Parser-only option- Returns:
- whether invalid unicode surrogate pairs should be allowed
- Since:
- 1.1.0
-
isQuoteSingle
public boolean isQuoteSingle()
Whether strings should be single-quoted (') instead of double-quoted ("). This also includes aJSONObject'smember namesDefault:
falseThis is a
Stringify-only option- Returns:
- whether strings should be single-quoted
- Since:
- 1.1.0
-
isAllowBinaryLiterals
public boolean isAllowBinaryLiterals()
- Returns:
- whether binary literals should be allowed
- Since:
- 2.0.0
-
isAllowOctalLiterals
public boolean isAllowOctalLiterals()
- Returns:
- whether octal literals should be allowed
- Since:
- 2.0.0
-
isAllowHexFloatingLiterals
public boolean isAllowHexFloatingLiterals()
Whether hexadecimal floating-point literals (e.g.0xA.BCp+12) should be allowedDefault:
falseThis is a
Parser-only option- Returns:
- whether octal literals should be allowed
- Since:
- 2.0.0
-
isAllowJavaDigitSeparators
public boolean isAllowJavaDigitSeparators()
Whether Java-style digit separators (123_456) should be allowedDefault:
falseThis is a
Parser-only option- Returns:
- whether Java-style digit separators should be allowed
- Since:
- 2.0.0
-
isAllowCDigitSeparators
public boolean isAllowCDigitSeparators()
Whether C-style digit separators (123'456) should be allowedDefault:
falseThis is a
Parser-only option- Returns:
- whether C-style digit separators should be allowed
- Since:
- 2.0.0
-
isAllowLongUnicodeEscapes
public boolean isAllowLongUnicodeEscapes()
Whether 32-bit unicode escape sequences (\U00123456) should be allowedDefault:
falseThis is a
Parser-only option- Returns:
- whether 32-bit unicode escape sequences should be allowed
- Since:
- 2.0.0
-
getDuplicateBehaviour
public JSONOptions.DuplicateBehavior getDuplicateBehaviour()
Specifies the behavior when the same key is encountered multiple times within the sameJSONObjectDefault:
UNIQUEThis is a
Parser-only option- Returns:
- the behavior when encountering duplicate keys
- Since:
- 1.3.0
-
getDefaultOptions
@NonNull public static @NonNull JSONOptions getDefaultOptions()
Returns the default options for parsing and stringifying- Returns:
- the default options
- Since:
- 1.1.0
-
setDefaultOptions
public static void setDefaultOptions(@NonNull @NonNull JSONOptions defaultOptions)Sets the default options for parsing and stringifying. Must not benull- Parameters:
defaultOptions- the new default options- Since:
- 1.1.0
-
-