Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Spring Boot Jackson map JSON response from 3rd party API to custom Object

I want to create a Java class out of a json response I get from a third party API which I have already managed to to with using the ObjectMapper. However, in this specific case, the JSON response has no keys so I dont know how I can map this into an Object, basically how should I use @JsonProperty annotation if the json response looks like this

[
[
1499040000000,      // Kline open time
"0.01634790",       // Open price
"0.80000000",       // High price
"0.01575800",       // Low price
"0.01577100",       // Close price
"148976.11427815",  // Volume
1499644799999,      // Kline Close time
"2434.19055334",    // Quote asset volume
308,                // Number of trades
"1756.87402397",    // Taker buy base asset volume
"28.46694368",      // Taker buy quote asset volume
"0"                 // Unused field, ignore.
]
]

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You want to use:

@JsonFormat(shape = JsonFormat.Shape.ARRAY)
@JsonPropertyOrder({ "foo", "bar" })
public class FooBar {
  public String foo;
  public String bar;
}

Example here:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading