JsonWriteFeature (Jackson-core 2.13.0 API)
Date: 2021-09-30

com.fasterxml.jackson.core.json

## Enum JsonWriteFeature

- java.lang.Object
- - java.lang.Enum<JsonWriteFeature>
  - - com.fasterxml.jackson.core.json.JsonWriteFeature

- All Implemented Interfaces:
    FormatFeature, JacksonFeature, Serializable, Comparable<JsonWriteFeature>

      public enum JsonWriteFeature
      extends Enum<JsonWriteFeature>
      implements FormatFeature

  Token writer features specific to JSON backend.
  Since:
    2.10

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `ESCAPE_NON_ASCII` Feature that specifies that all characters beyond 7-bit ASCII range (i.e.
    `QUOTE_FIELD_NAMES` Feature that determines whether JSON Object field names are quoted using double-quotes, as specified by JSON specification or not.
    `WRITE_NAN_AS_STRINGS` Feature that determines whether "NaN" ("not a number", that is, not real number) float/double values are output as JSON strings.
    `WRITE_NUMBERS_AS_STRINGS` Feature that forces all regular number values to be written as JSON Strings, instead of as JSON Numbers.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `collectDefaults()` Method that calculates bit set (flags) of all features that are enabled by default.
    `boolean` | `enabledByDefault()` Accessor for checking whether this feature is enabled by default.
    `boolean` | `enabledIn(int flags)` Convenience method for checking whether feature is enabled in given bitmask
    `int` | `getMask()` Returns bit mask for this feature instance; must be a single bit, that is of form `(1 << N)`
    `JsonGenerator.Feature` | `mappedFeature()`
    `static JsonWriteFeature` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static JsonWriteFeature[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### QUOTE_FIELD_NAMES

          public static final JsonWriteFeature QUOTE_FIELD_NAMES

      Feature that determines whether JSON Object field names are quoted using double-quotes, as specified by JSON specification or not. Ability to disable quoting was added to support use cases where they are not usually expected, which most commonly occurs when used straight from Javascript.

      Feature is enabled by default (since it is required by JSON specification).

    - #### WRITE_NAN_AS_STRINGS

          public static final JsonWriteFeature WRITE_NAN_AS_STRINGS

      Feature that determines whether "NaN" ("not a number", that is, not real number) float/double values are output as JSON strings. The values checked are Double.Nan, Double.POSITIVE_INFINITY and Double.NEGATIVE_INIFINTY (and associated Float values). If feature is disabled, these numbers are still output using associated literal values, resulting in non-conforming output.

      Feature is enabled by default.

    - #### WRITE_NUMBERS_AS_STRINGS

          public static final JsonWriteFeature WRITE_NUMBERS_AS_STRINGS

      Feature that forces all regular number values to be written as JSON Strings, instead of as JSON Numbers. Default state is 'false', meaning that Java numbers are to be serialized using basic numeric representation but if enabled all such numeric values are instead written out as JSON Strings instead.

      One use case is to avoid problems with Javascript limitations: since Javascript standard specifies that all number handling should be done using 64-bit IEEE 754 floating point values, result being that some 64-bit integer values can not be accurately represent (as mantissa is only 51 bit wide).

      Feature is disabled by default.

    - #### ESCAPE_NON_ASCII

          public static final JsonWriteFeature ESCAPE_NON_ASCII

      Feature that specifies that all characters beyond 7-bit ASCII range (i.e. code points of 128 and above) need to be output using format-specific escapes (for JSON, backslash escapes), if format uses escaping mechanisms (which is generally true for textual formats but not for binary formats).

      Feature is disabled by default.

  - ### Method Detail

    - #### values

          public static JsonWriteFeature[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (JsonWriteFeature c : JsonWriteFeature.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static JsonWriteFeature valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### collectDefaults

          public static int collectDefaults()

      Method that calculates bit set (flags) of all features that are enabled by default.
      Returns:
        Bit mask of all features that are enabled by default

    - #### enabledByDefault

          public boolean enabledByDefault()

      Description copied from interface: `FormatFeature`
      Accessor for checking whether this feature is enabled by default.
      Specified by:
        `enabledByDefault` in interface `FormatFeature`
      Specified by:
        `enabledByDefault` in interface `JacksonFeature`
      Returns:
        Whether this instance is enabled by default or not

    - #### getMask

          public int getMask()

      Description copied from interface: `FormatFeature`
      Returns bit mask for this feature instance; must be a single bit, that is of form `(1 << N)`
      Specified by:
        `getMask` in interface `FormatFeature`
      Specified by:
        `getMask` in interface `JacksonFeature`
      Returns:
        Bit mask of this feature

    - #### enabledIn

          public boolean enabledIn(int flags)

      Description copied from interface: `FormatFeature`
      Convenience method for checking whether feature is enabled in given bitmask
      Specified by:
        `enabledIn` in interface `FormatFeature`
      Specified by:
        `enabledIn` in interface `JacksonFeature`
      Parameters:
        `flags` - Bit field that contains a set of enabled features of this type
      Returns:
        True if this feature is enabled in passed bit field

    - #### mappedFeature

          public JsonGenerator.Feature mappedFeature()

Copyright © 2008–2021 FasterXML. All rights reserved.