Skip to content

Commit

Permalink
provide NaN and Infinity when (de)serializing Java Numbers
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos committed Oct 6, 2021
1 parent e865594 commit 5f6d118
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions api/src/main/java/jakarta/json/stream/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ public interface JsonGenerator extends Flushable, /*Auto*/Closeable {
*/
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";

/**
* Writes the JSON start object character. It starts a new child object
* context within which JSON name/value pairs can be written to the object.
Expand Down Expand Up @@ -336,7 +350,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 JsonGenerator#WRITE_NAN_AS_NULLS} and/or {@link JsonGenerator#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 +501,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 JsonGenerator#WRITE_NAN_AS_NULLS} and/or {@link JsonGenerator#WRITE_NAN_AS_STRINGS}
* is not set.
*/
JsonGenerator write(double value);

Expand Down

0 comments on commit 5f6d118

Please sign in to comment.