Module json5

Class JSONOptions

java.lang.Object
at.syntaxerror.json5.JSONOptions

public class JSONOptions extends Object
This class used is used to customize the behaviour of parsing and stringifying
Since:
1.1.0
Author:
SyntaxError404
  • Method Details

    • builder

      public static JSONOptions.JSONOptionsBuilder builder()
    • toBuilder

      public JSONOptions.JSONOptionsBuilder toBuilder()
    • isParseInstants

      public boolean isParseInstants()
      Whether instants should be parsed as such. If this is false, isParseStringInstants() and isParseUnixInstants() are ignored

      Default: true

      This is a Parser-only option

      Returns:
      whether instants should be parsed
      Since:
      1.1.0
    • isParseStringInstants

      public boolean isParseStringInstants()
      Whether string instants (according to RFC 3339, Section 5.6) should be parsed as such. Ignored if isParseInstants() is false

      Default: true

      This is a Parser-only option

      Returns:
      whether string instants should be parsed
      Since:
      1.1.0
    • isParseUnixInstants

      public boolean isParseUnixInstants()
      Whether unix instants (integers) should be parsed as such. Ignored if isParseInstants() is false

      Default: true

      This is a Parser-only option

      Returns:
      whether unix instants should be parsed
      Since:
      1.1.0
    • isStringifyUnixInstants

      public boolean isStringifyUnixInstants()
      Whether instants should be stringifyed as unix timestamps. If this is false, instants will be stringifyed as strings (according to RFC 3339, Section 5.6).

      Default: false

      This is a Stringify-only option

      Returns:
      whether instants should be stringifyed as unix timestamps
      Since:
      1.1.0
    • isAllowNaN

      public boolean isAllowNaN()
      Whether NaN should be allowed as a number

      Default: true

      Returns:
      whether NaN should be allowed
      Since:
      1.1.0
    • isAllowInfinity

      public boolean isAllowInfinity()
      Whether Infinity should be allowed as a number. This applies to both +Infinity and -Infinity

      Default: true

      Returns:
      whether Infinity should be allowed
      Since:
      1.1.0
    • isAllowInvalidSurrogates

      public boolean isAllowInvalidSurrogates()
      Whether invalid unicode surrogate pairs should be allowed

      Default: true

      This 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 a JSONObject's member names

      Default: false

      This is a Stringify-only option

      Returns:
      whether strings should be single-quoted
      Since:
      1.1.0
    • getDuplicateBehaviour

      public JSONOptions.DuplicateBehavior getDuplicateBehaviour()
      Specifies the behavior when the same key is encountered multiple times within the same JSONObject

      Default: UNIQUE

      This 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 be null
      Parameters:
      defaultOptions - the new default options
      Since:
      1.1.0