Consuming rest with spring with nested json

I've followed a tutorial to consume a rest service. The tutorial only mentions a single layer JSON file. However i'd like to parse a json like

Foo: {
 fooz: 'stringdescripoers}
 bar : {
    baz: "something",
    etc: [[1,2],[2,0]]
{another object like bar},

Having set up the project according tot the turtorial with maven i have the following main class

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

public class Application {

    public static void main(String args[]) {
        RestTemplate restTemplate = new RestTemplate();
        FeatureCollection collection = restTemplate.getForObject("", FeatureCollection.class);
        System.out.println("it worked");

and my class looks like this.

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class FeatureCollection {

    private String type;

    public String getType() {
        return type;

When i run this through spring-boot run i get the following results in my command line:

tons of info,

[INFO] Attaching agents: []
14:54:02.566 [main] DEBUG o.s.web.client.RestTemplate - Created GET request for ""
14:54:02.634 [main] DEBUG o.s.web.client.RestTemplate - Setting request Accept header to [application/json, application/*+json]
14:54:02.719 [main] DEBUG o.s.web.client.RestTemplate - GET request for "" resulted in 200 (OK)
Exception in thread "main" org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class FeatureCollection] and content type [text/plain;charset=UTF-8]
        at org.springframework.web.client.HttpMessageConverterExtractor.extractData(
        at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(
        at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(
        at org.springframework.web.client.RestTemplate.doExecute(
        at org.springframework.web.client.RestTemplate.execute(
        at org.springframework.web.client.RestTemplate.getForEntity(
        at Application.main(

Is there something I'm not seeing?


Could not extract response: no suitable HttpMessageConverter found for response type [class FeatureCollection] and content type [text/plain;charset=UTF-8]

Check your dependencies to see if you have Jackson Message converter in there. You need that to convert the JSON you are consuming to Java object. If its in your dependencies than I think if you use @SpringBootApplication on top of your main class, Spring will automatically convert the JSON you are consuming to the Java object.

In eclipse, try going to new --> Spring starter project --> and select web, and maybe rest, then use that project to consume rest.

Need Your Help

Searching numeric data using Solr

database search solr search-engine numerical-methods

I am using Solr for (an unusual?) use-case of providing ranked results for numeric data./