The api is returning many rows.. how to handle that?

the api is returning many rows… how to handle that???
And what to write in
List collection = mapper.readValue(result, new TypeReference<ArrayList>() {

Any hints


Hi, read the TODOs. You have to use a POJO class which has been defined for you already by the crio team.

String result = restTemplate.getForObject(url, String.class);
TiingoCandle ca = mp.readValue(result, TiingoCandle.class);
is this correct??

The API is returning a list of JSON objects. So you will have to create a list of objects of class TiingoCandle just like you did in milestone 1.

like this
TiingoCandle [] ca = mp.readValue(result, TiingoCandle[].class);

I am sure you know how to declare a LIST objects.

Are you talking about this
List collection = mapper.readValue(result, new TypeReference<ArrayList>() {
But i am not getting what to write inside of this

This is wrong. The earlier one was correct. Just change the declaration. You have to declare a list of tiingocancle objects. Remember how to declare a list.

List < Type > obj;

Hey jayansh! Your approach seems to be right. Try exploring Arrays class inbuilt method. That might help you convert the array to list.

Upvote if useful! Happy coding. :slightly_smiling_face:

Hey , i am only having one POJO class which i have made in module 1? not any other pojo class?

The crio team has already made POJO classes which are needed in different modules. Read the TODOs and look at the DTO folder in your workspace. Look at the different classes present there and find the most suitable one for the particular module.

1 Like

Hey did you get how to solve the issue. I am also stuck at the same place.
TiingoCandle[] tc = obj.readValue(result, TiingoCandle[].class);
Is this correct?

Hi, how had you parsed json in module 1? Just do it like that only. It will work.

How did you parsed the trade.json file in module 1? Remeber that object mapper can give you either the object or a list of objects. Analyse again what you are getting here from Tiingo API ? Should you use a list of tingocandle objects or a single tiingocandle object?
Hint : Try looking at TiingoCandle class given by CRIO team.
Hope it helps! :wink: