0

I'm trying to consume this data

https://api.nasa.gov/neo/rest/v1/neo/browse?api_key=DEMO_KEY

following the tutorial from

http://spring.io/guides/gs/consuming-rest/

I successfully retrieve the "links" and "page" portions of the data, but the array of near_earth_objects is null.

I tried what was suggested in this post:

Get list of JSON objects with Spring RestTemplate

But my situation is a little more complicated because it's more than just one array filled with objects as seen in

http://bitpay.com/api/rates

Top answer gives error:

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not 
deserialize instance of java.lang.Object[] out of START_OBJECT token

Here is what my POJO looks like:

@JsonIgnoreProperties(ignoreUnknown = true)
public class NearEarthObjectBrowse {
    @Id
    private Links links;
    private Page page;
    private NearEarthObject[] near_earth_objects;

I also tried using a wrapper class for the NearEarthObject array and still was unable to marshal successfully.

Is there a better way to go about doing this in general?

Edit: I believe the structure of NearEarthObject matches the data. Here is my github

Community
  • 1
  • 1

1 Answers1

0

Try to use A list instead of an array for near_earth_objects

@JsonProperty("near_earth_objects")
private List<NearEarthObject> near_earth_objects;