Skip to content

Commit

Permalink
WW-4537 Support for latest jackson lib as json content handler in res…
Browse files Browse the repository at this point in the history
…t plugin
  • Loading branch information
jogep committed Aug 23, 2015
1 parent 3bd1b7a commit 0fac539
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 8 additions & 5 deletions plugins/rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<packaging>jar</packaging>

<properties>
<jackson.version>1.9.2</jackson.version>
<jackson.version>2.6.1</jackson.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -48,15 +48,18 @@
<artifactId>json-lib</artifactId>
<classifier>jdk15</classifier>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

package org.apache.struts2.rest.handler;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.StrutsConstants;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectReader;
import org.codehaus.jackson.map.SerializationConfig.Feature;

import java.io.IOException;
import java.io.Reader;
Expand All @@ -41,14 +41,13 @@ public class JacksonLibHandler implements ContentTypeHandler {
private ObjectMapper mapper = new ObjectMapper();

public void toObject(Reader in, Object target) throws IOException {

mapper.configure(Feature.WRITE_NULL_MAP_VALUES, false);
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
ObjectReader or = mapper.readerForUpdating(target);
or.readValue(in); //, new TypeReference<clazz>);
or.readValue(in);
}

public String fromObject(Object obj, String resultCode, Writer stream) throws IOException {
mapper.configure(Feature.WRITE_NULL_MAP_VALUES, false);
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
mapper.writeValue(stream, obj);
return null;
}
Expand Down

0 comments on commit 0fac539

Please sign in to comment.