Class NumberToJSON


  • public final class NumberToJSON
    extends java.lang.Object
    An implementation of Ryu for serializing IEEE-754 double precision values for JSON as specified by ES6
    • Constructor Summary

      Constructors 
      Constructor Description
      NumberToJSON()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String serializeNumber​(double value)
      Formats a number according to ES6.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NumberToJSON

        public NumberToJSON()
    • Method Detail

      • serializeNumber

        public static java.lang.String serializeNumber​(double value)
                                                throws java.io.IOException
        Formats a number according to ES6.

        This code is emulating 7.1.12.1 of the EcmaScript V6 specification.

        Parameters:
        value - Value to be formatted
        Returns:
        String representation
        Throws:
        java.io.IOException - NaN/Infinity