io.keen.client.java
Interface KeenJsonHandler


public interface KeenJsonHandler

Interface for abstracting the tasks of converting an input Reader into an in-memory object (in the form of a Map<String, Object>), and for writing that object back out to a Writer.

This interface allows the Keen library to be configured to use different JSON implementations in different environments, depending upon requirements for speed versus size (or other considerations).

Since:
2.0.0

Method Summary
 java.util.Map<java.lang.String,java.lang.Object> readJson(java.io.Reader reader)
          Reads JSON-formatted data from the provided Reader and constructs a Map representing the object described.
 void writeJson(java.io.Writer writer, java.util.Map<java.lang.String,?> value)
          Writes the given object (in the form of a Map<String, Object> to the specified Writer.
 

Method Detail

readJson

java.util.Map<java.lang.String,java.lang.Object> readJson(java.io.Reader reader)
                                                          throws java.io.IOException
Reads JSON-formatted data from the provided Reader and constructs a Map representing the object described. The keys of the map should correspond to the names of the top-level members, and the values may primitives (Strings, Integers, Booleans, etc.), Maps, or Iterables.

Parameters:
reader - The Reader from which to read the JSON data.
Returns:
The object which was read, held in a Map<String, Object>.
Throws:
java.io.IOException - If there is an error reading from the input.

writeJson

void writeJson(java.io.Writer writer,
               java.util.Map<java.lang.String,?> value)
               throws java.io.IOException
Writes the given object (in the form of a Map<String, Object> to the specified Writer.

Parameters:
writer - The Writer to which the JSON data should be written.
value - The object to write.
Throws:
java.io.IOException - If there is an error writing to the output.