public class JSONOptions
extends java.lang.Object
FileUtils class). For example:
By default saving or reading will use a default options which content can be modified. For example:
INDENT_DEFAULT: the default indentation typeINDENT_ALL: all fields are indentedINDENT_OBJECTS: only objects and arrays fields are indented| Modifier and Type | Field and Description |
|---|---|
static short |
INDENT_ALL
The "All" indentation type.
|
static short |
INDENT_DEFAULT
The default indentation type.
|
static short |
INDENT_OBJECTS
The object indentation type.
|
| Constructor and Description |
|---|
JSONOptions() |
| Modifier and Type | Method and Description |
|---|---|
JSONOptions |
acceptJavascriptComments(boolean accept)
Set if javascript comments should be accepted.
|
static JSONOptions |
createOptions()
Return a new JSONOptions with default parameters values.
|
java.lang.String |
getCharset()
Return the charset to use when reading or writing JSON content.
|
static JSONOptions |
getDefault()
Return the default options.
|
short |
getIndentationType()
Return the result indentation type.
|
int |
getIndentFactor()
Return the number of spaces to add to each level of indentation.
|
static JSONOptions |
getOptions(JSONOptions options)
Return a not null JSONOptions.
|
boolean |
isAcceptingJavascriptComments()
Return true if javascript comments should be accepted.
|
boolean |
isKeepingDecimalPoints()
Return true if decimal points must be kept in the serialized results for decimal values.
|
boolean |
isKeepingKeysNaturalOrder()
Return true if the keys natural order should be kept.
|
boolean |
isKeepingXMLStrings()
Return true if values will not be coerced into boolean or numeric values and will instead be left as strings.
|
JSONOptions |
keepDecimalPoints(boolean keepDecimalPoints)
Set if decimal points must be kept in the serialized results for decimal values.
|
JSONOptions |
keepKeysNaturalOrder(boolean keysNaturalOrder)
Set if the keys natural order should be kept.
|
JSONOptions |
keepXMLStrings(boolean keepXMLStrings)
Set if values will not be coerced into boolean or numeric values and will instead be left as strings.
|
void |
reset()
Reset this options values.
|
static JSONOptions |
resetDefault()
Reset the default options.
|
JSONOptions |
setCharSetName(java.lang.String charset)
Set the charset to use when reading or writing JSON content.
|
static JSONOptions |
setDefaultAcceptJavascriptComments(boolean accept)
Set if javascript comments should be accepted, for the default options..
|
static JSONOptions |
setDefaultCharSetName(java.lang.String charset)
Set the charset to use when reading or writing JSON content, for the default options.
|
static JSONOptions |
setDefaultIndentationType(short indentType)
Set the result indentation type, for the default options.
|
static JSONOptions |
setDefaultIndentFactor(int indentFactor)
Set the number of spaces to add to each level of indentation, for the default options.
|
static JSONOptions |
setDefaultKeepDecimalPoints(boolean keepDecimalPoints)
Set if decimal points must be kept in the serialized results for decimal values, for the default options.
|
static JSONOptions |
setDefaultKeepKeysNaturalOrder(boolean keysNaturalOrder)
Set if the keys natural order should be kept, for the default options.
|
static JSONOptions |
setDefaultKeepXMLStrings(boolean keepXMLStrings)
Set if values will not be coerced into boolean or numeric values and will instead be left as strings, for the default options.
|
JSONOptions |
setIndentationType(short indentType)
Set the result indentation type.
|
JSONOptions |
setIndentFactor(int indentFactor)
Set the number of spaces to add to each level of indentation.
|
public static final short INDENT_DEFAULT
public static final short INDENT_OBJECTS
public static final short INDENT_ALL
public static JSONOptions getDefault()
FileUtils.toFile(org.json.JSONElement, java.io.File).public static JSONOptions resetDefault()
public void reset()
public static JSONOptions createOptions()
public static JSONOptions getOptions(JSONOptions options)
options - the provided JSONOptions (may be null)public static JSONOptions setDefaultKeepDecimalPoints(boolean keepDecimalPoints)
keepDecimalPoints - true if decimal points must be kept in the results for decimal valuespublic JSONOptions keepDecimalPoints(boolean keepDecimalPoints)
keepDecimalPoints - true if decimal points must be kept in the results for decimal valuespublic boolean isKeepingDecimalPoints()
public static JSONOptions setDefaultCharSetName(java.lang.String charset)
charset - true the charsetpublic JSONOptions setCharSetName(java.lang.String charset)
charset - true the charsetpublic java.lang.String getCharset()
public static JSONOptions setDefaultAcceptJavascriptComments(boolean accept)
accept - true if javascript comments should be acceptedpublic JSONOptions acceptJavascriptComments(boolean accept)
accept - true if javascript comments should be acceptedpublic boolean isAcceptingJavascriptComments()
public static JSONOptions setDefaultKeepKeysNaturalOrder(boolean keysNaturalOrder)
keysNaturalOrder - true if the keys natural order must be keptpublic JSONOptions keepKeysNaturalOrder(boolean keysNaturalOrder)
keysNaturalOrder - true if the keys natural order must be keptpublic boolean isKeepingKeysNaturalOrder()
public static JSONOptions setDefaultKeepXMLStrings(boolean keepXMLStrings)
keepXMLStrings - true if values will not be coerced into boolean or numeric values and will instead be left as stringspublic JSONOptions keepXMLStrings(boolean keepXMLStrings)
keepXMLStrings - true if values will not be coerced into boolean or numeric values and will instead be left as stringspublic boolean isKeepingXMLStrings()
public static JSONOptions setDefaultIndentFactor(int indentFactor)
indentFactor - the indent factorpublic JSONOptions setIndentFactor(int indentFactor)
indentFactor - the indent factorpublic int getIndentFactor()
public static JSONOptions setDefaultIndentationType(short indentType)
INDENT_DEFAULT: the default indentation typeINDENT_ALL: all fields are indentedINDENT_OBJECTS: only objects and arrays fields are indentedindentType - the result indentation typepublic JSONOptions setIndentationType(short indentType)
INDENT_DEFAULT: the default indentation typeINDENT_ALL: all fields are indentedINDENT_OBJECTS: only objects and arrays fields are indentedindentType - the result indentation typepublic short getIndentationType()
Copyright (C) 2017 Wei Song. Copyright (c) 2002 JSON.org. Copyright © 2018, 2019, 2026 Herve Girod. All Rights Reserved. elasticlunr Documentation and source under the MIT licence. JSON Documentation and source under the JSON licence