Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide NaN and Infinity when (de)serializing Java Numbers #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions api/src/main/java/jakarta/json/JsonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
*/
public final class JsonConfig {

/**
* Configuration property to generate JSON prettily. All providers
* must support this property. The value of the property could be
* be anything.
*/
String PRETTY_PRINTING = "jakarta.json.stream.JsonGenerator.prettyPrinting" ;

/**
* Configuration property to generate NaN, +Infinity and -Infinity as nulls.
*
* @since 2.1
*/
String WRITE_NAN_AS_NULLS = "jakarta.json.stream.JsonGenerator.writeNanAsNulls";

/**
* Configuration property to generate NaN, +Infinity and -Infinity as Strings.
*
* @since 2.1
*/
String WRITE_NAN_AS_STRINGS = "jakarta.json.stream.JsonGenerator.writeNanAsStrings";

/**
* Configuration property to define the strategy for handling duplicate keys.
*
Expand Down
14 changes: 6 additions & 8 deletions api/src/main/java/jakarta/json/stream/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@
* @see JsonGeneratorFactory
*/
public interface JsonGenerator extends Flushable, /*Auto*/Closeable {
/**
* Configuration property to generate JSON prettily. All providers
* must support this property. The value of the property could be
* be anything.
*/
String PRETTY_PRINTING = "jakarta.json.stream.JsonGenerator.prettyPrinting" ;

/**
* Writes the JSON start object character. It starts a new child object
Expand Down Expand Up @@ -336,7 +330,9 @@ public interface JsonGenerator extends Flushable, /*Auto*/Closeable {
* @return this generator
* @throws jakarta.json.JsonException if an i/o error occurs (IOException
* would be cause of JsonException)
* @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity.
* @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity
* when {@link jakarta.json.JsonConfig#WRITE_NAN_AS_NULLS} and/or
* {@link jakarta.json.JsonConfig#WRITE_NAN_AS_STRINGS} is not set.
* @throws JsonGenerationException if this method is not called within an
* object context
*/
Expand Down Expand Up @@ -485,7 +481,9 @@ public interface JsonGenerator extends Flushable, /*Auto*/Closeable {
* would be cause of JsonException)
* @throws JsonGenerationException if this method is not called within an
* array or root context.
* @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity.
* @throws NumberFormatException if the value is Not-a-Number (NaN) or infinity
* when {@link jakarta.json.JsonConfig#WRITE_NAN_AS_NULLS} and/or
* {@link jakarta.json.JsonConfig#WRITE_NAN_AS_STRINGS} is not set.
*/
JsonGenerator write(double value);

Expand Down