org.apache.solr.common.util

## Class SolrJSONWriter

- java.lang.Object
- - org.apache.solr.common.util.SolrJSONWriter

All Implemented Interfaces:
  Closeable, AutoCloseable, PushWriter, JsonTextWriter, TextWriter

    public class SolrJSONWriter
    extends Object
    implements JsonTextWriter

Use this to serialize an object into Json. This only supports standard Objects and not the server-side Objects

### Field Summary

Fields
`protected boolean` `doIndent`
`protected int` `level`
`protected String` `namedListStyle`

### Fields inherited from interface org.apache.solr.common.util.JsonTextWriter

`hexdigits, JSON_NL_ARROFARR, JSON_NL_ARROFMAP, JSON_NL_ARROFNTV, JSON_NL_FLAT, JSON_NL_MAP, JSON_NL_STYLE`

### Constructor Summary

Constructors
Constructor and Description
`SolrJSONWriter(Writer writer)`
`SolrJSONWriter(Writer writer, String namedListStyle)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `_writeChar(char c)`
`void` `_writeStr(String s)`
`void` `close()` done with all writing
`int` `decLevel()`
`boolean` `doIndent()`
`String` `getNamedListStyle()`
`Writer` `getWriter()`
`int` `incLevel()`
`int` `level()`
`SolrJSONWriter` `setIndent(boolean doIndent)`
`void` `setLevel(int level)`
`SolrJSONWriter` `writeObj(Object o)`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.solr.common.util.JsonTextWriter

`unicodeEscape, writeArray, writeArray, writeArrayCloser, writeArrayOpener, writeArraySeparator, writeBool, writeDate, writeDouble, writeFloat, writeInt, writeIterator, writeJsonIter, writeKey, writeLong, writeMap, writeMap, writeMapCloser, writeMapOpener, writeMapSeparator, writeNamedList, writeNamedListAsArrArr, writeNamedListAsArrMap, writeNamedListAsFlat, writeNamedListAsMapMangled, writeNamedListAsMapWithDups, writeNull, writeStr`

### Methods inherited from interface org.apache.solr.common.util.TextWriter

`indent, indent, writeArray, writeBool, writeBool, writeByteArr, writeDate, writeDouble, writeFloat, writeInt, writeIterator, writeLong, writeMap, writeNumber, writeVal`

### Field Detail

#### namedListStyle

    protected final String namedListStyle

#### level

    protected int level

#### doIndent

    protected boolean doIndent

### Constructor Detail

#### SolrJSONWriter

    public SolrJSONWriter(Writer writer)

#### SolrJSONWriter

    public SolrJSONWriter(Writer writer,
                          String namedListStyle)

### Method Detail

#### writeObj

    public SolrJSONWriter writeObj(Object o)
                            throws IOException

Throws:
  `IOException`

#### close

    public void close()
               throws IOException

done with all writing

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Throws:
  `IOException`

#### getNamedListStyle

    public String getNamedListStyle()

Specified by:
  `getNamedListStyle` in interface `JsonTextWriter`

#### _writeChar

    public void _writeChar(char c)
                    throws IOException

Specified by:
  `_writeChar` in interface `JsonTextWriter`
Throws:
  `IOException`

#### _writeStr

    public void _writeStr(String s)
                   throws IOException

Specified by:
  `_writeStr` in interface `JsonTextWriter`
Throws:
  `IOException`

#### setLevel

    public void setLevel(int level)

#### level

    public int level()

Specified by:
  `level` in interface `TextWriter`

#### incLevel

    public int incLevel()

Specified by:
  `incLevel` in interface `TextWriter`

#### decLevel

    public int decLevel()

Specified by:
  `decLevel` in interface `TextWriter`

#### setIndent

    public SolrJSONWriter setIndent(boolean doIndent)

Specified by:
  `setIndent` in interface `TextWriter`

#### doIndent

    public boolean doIndent()

Specified by:
  `doIndent` in interface `TextWriter`

#### getWriter

    public Writer getWriter()

Specified by:
  `getWriter` in interface `TextWriter`