Struts 2
  1. Struts 2
  2. WW-3629

Provide a JSON Content Handler based on Jackson Lib

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.1
    • Component/s: Plugin - REST
    • Labels:

      Description

      Provide a JSON Content Handler based on Jackson Lib:

      http://jackson.codehaus.org/

      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

      { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(Feature.WRITE_NULL_MAP_VALUES, false); objectMapper.writeValue(writer, object); }

      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"; }

      }

        Activity

        Hide
        Hudson added a comment -

        Integrated in Struts2 #374 (See https://builds.apache.org/job/Struts2/374/)
        WW-3629: Provide a JSON Content Handler based on Jackson Lib

        jogep :
        Files :

        • /struts/struts2/trunk/plugins/rest/pom.xml
        • /struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/handler/JacksonLibHandler.java
        • /struts/struts2/trunk/plugins/rest/src/test/java/org/apache/struts2/rest/handler/JacksonLibHandlerTest.java
        Show
        Hudson added a comment - Integrated in Struts2 #374 (See https://builds.apache.org/job/Struts2/374/ ) WW-3629 : Provide a JSON Content Handler based on Jackson Lib jogep : Files : /struts/struts2/trunk/plugins/rest/pom.xml /struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/handler/JacksonLibHandler.java /struts/struts2/trunk/plugins/rest/src/test/java/org/apache/struts2/rest/handler/JacksonLibHandlerTest.java
        Hide
        Frans Thamura added a comment -

        glad our code can be part of the struts2.. http://cimande.java.net

        the jackson is cool, because implement JSONFactory, that will give us benefit.

        NB: I prefer JPA with JSON rather current Hibernate

        Frans

        Show
        Frans Thamura added a comment - glad our code can be part of the struts2.. http://cimande.java.net the jackson is cool, because implement JSONFactory, that will give us benefit. NB: I prefer JPA with JSON rather current Hibernate Frans

          People

          • Assignee:
            Johannes Geppert
            Reporter:
            Johannes Geppert
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 4h
              4h
              Remaining:
              Remaining Estimate - 4h
              4h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development