Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
Description
Provide a JSON Content Handler based on Jackson Lib:
Jackson is a:
Streaming (reading, writing)
FAST (measured to be faster than any other Java json parser and data binder)
Powerful (full data binding for common JDK classes as well as any Java bean class, Collection, Map or Enum)
Zero-dependency (does not rely on other packages beyond JDK)
Open Source (LGPL or AL)
Fully conformant
Extremely configurable
JSON processor (JSON parser + JSON generator) written in Java. Beyond basic JSON reading/writing (parsing, generating), it also offers full node-based Tree Model, as well as full OJM (Object/Json Mapper) data binding functionality.
A Content Handler can look like this:
import java.io.IOException;
import java.io.Writer;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig.Feature;
public class JsonContentHandler implements ContentHandler {
public void fromObject(Object object, Writer writer) {
try
catch (JsonGenerationException e)
{ e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); }catch (IOException e)
{ e.printStackTrace(); }}
public String getContentType()
{ return "application/json"; }public String getExtension()
{ return "json"; }}