Created
May 31, 2011 22:39
-
-
Save jawher/1001433 to your computer and use it in GitHub Desktop.
JAX-RS JSON List<String>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.sun.jersey</groupId> | |
<artifactId>jersey-server</artifactId> | |
<version>1.6</version> | |
</dependency> | |
<dependency> | |
<groupId>com.sun.jersey</groupId> | |
<artifactId>jersey-json</artifactId> | |
<version>1.6</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("/test") | |
public class Resource { | |
@GET | |
@Produces("application/json") | |
public List<String> pascal() { | |
return Arrays.asList("a", "b"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RestApplication extends Application { | |
@Override | |
public Set<Object> getSingletons() { | |
Set<Object> res = new HashSet<Object>(); | |
res.add(new JacksonJsonProvider()); | |
return res; | |
} | |
@Override | |
public Set<Class<?>> getClasses() { | |
: | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
["a","b"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<servlet> | |
<servlet-name>RestRestlet</servlet-name> | |
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> | |
<init-param> | |
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> | |
<param-value>true</param-value> | |
</init-param> | |
<init-param> | |
<param-name>javax.ws.rs.Application</param-name> | |
<param-value>RestApplication</param-value> | |
</init-param> | |
</servlet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment