Package org.ldaptive.io
Class JsonWriter
- java.lang.Object
-
- org.ldaptive.io.JsonWriter
-
- All Implemented Interfaces:
SearchResultWriter
public class JsonWriter extends Object implements SearchResultWriter
Writes aSearchResponseas JSON to aWriter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJsonWriter.SearchResultSerializerSerializes aSearchResponseby creating a json array to contain the entries.
-
Field Summary
Fields Modifier and Type Field Description private com.google.gson.GsongsonTo convert a search result to JSON.private WriterjsonWriterWriter to write to.
-
Constructor Summary
Constructors Constructor Description JsonWriter(Writer writer)Creates a new json writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidwrite(SearchResponse result)Writes the supplied search result to the writer.
-
-
-
Field Detail
-
jsonWriter
private final Writer jsonWriter
Writer to write to.
-
gson
private final com.google.gson.Gson gson
To convert a search result to JSON.
-
-
Constructor Detail
-
JsonWriter
public JsonWriter(Writer writer)
Creates a new json writer.- Parameters:
writer- to write JSON to
-
-
Method Detail
-
write
public void write(SearchResponse result) throws IOException
Writes the supplied search result to the writer.- Specified by:
writein interfaceSearchResultWriter- Parameters:
result- search result to write- Throws:
IOException- if an error occurs using the writer
-
-