import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
private Client createJerseyClient()
{
// Configuration of Jersey client.
ClientConfig config = new DefaultClientConfig();
// Enable mapping between JSON and Java classes.
config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
// Create a Client instance.
return Client.create(config);
}
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
private Client createJerseyClient()
{
// Configuration of Jersey client.
ClientConfig config = new DefaultClientConfig();
// Enable mapping between JSON and Java classes.
config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true);
// Create a Client instance.
return Client.create(config);
}
Note that jersey-json-*.jar is needed. If you are using Maven, add a dependency entry like below.
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.16</version>
</dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.16</version>
</dependency>