Class JsonWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class JsonWriter
    extends java.io.Writer
    Builder style API for emitting JSON.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  JsonWriter.OutputType  
    • Field Summary

      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonWriter​(java.io.Writer writer)  
    • Constructor Detail

      • JsonWriter

        public JsonWriter​(java.io.Writer writer)
    • Method Detail

      • getWriter

        public java.io.Writer getWriter()
      • setQuoteLongValues

        public void setQuoteLongValues​(boolean quoteLongValues)
        When true, quotes long, double, BigInteger, BigDecimal types to prevent truncation in languages like JavaScript and PHP. This is not necessary when using libgdx, which handles these types without truncation. Default is false.
      • name

        public JsonWriter name​(java.lang.String name)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • object

        public JsonWriter object()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • array

        public JsonWriter array()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • value

        public JsonWriter value​(java.lang.Object value)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • json

        public JsonWriter json​(java.lang.String json)
                        throws java.io.IOException
        Writes the specified JSON value, without quoting or escaping.
        Throws:
        java.io.IOException
      • object

        public JsonWriter object​(java.lang.String name)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • array

        public JsonWriter array​(java.lang.String name)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • set

        public JsonWriter set​(java.lang.String name,
                              java.lang.Object value)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • json

        public JsonWriter json​(java.lang.String name,
                               java.lang.String json)
                        throws java.io.IOException
        Writes the specified JSON value, without quoting or escaping.
        Throws:
        java.io.IOException
      • pop

        public JsonWriter pop()
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
                   throws java.io.IOException
        Specified by:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer
        Throws:
        java.io.IOException