Essentially, this is the kind of data I want returned:
{
"Top10BidAsks":[
{
"Bid":{
"Price":10.0,
"Size":2.0,
"ExchangeID":"SMART",
"timeStamp":0
},
"Ask":{
"Price":12.0,
"Size":2.0,
"ExchangeID":"SMART",
"timeStamp":0
}
},
{
"Bid":{
"Price":0.0,
"Size":0.0,
"ExchangeID":"SMART",
"timeStamp":0
},
"Ask":{
"Price":13.0,
"Size":12.0,
"ExchangeID":"SMART",
"timeStamp":0
}
}
]
}
The {"Price":10.0,"Size":2.0,"ExchangeID":"SMART","timeStamp":0}, essentially represents a MarketData Object that I've created with those 4 fields.
The main function I'm calling is:
public MarketDataListLevel2 getMarketDataDepth() {
try {
MarketDataListLevel2 md = cs.getMarketDataDepth();
log.info(md.toString());
return md;
}
catch ( Exception e) {
....
}
}
Where cs is just an interface that retrieves the JSON data from a site.
The MarketDataLevel2 object is:
public class MarketDataListLevel2 {
public static class MarketDataList {
public MarketData[] a;
}
public MarketDataList[] listofmarketdatalists;
public MarketDataListLevel2(@JsonProperty("Top10BidAsks") MarketDataList[] listofmarketdatalists) {
this.listofmarketdatalists = listofmarketdatalists;
}
I tried to make this object match the output I want (formatting wise), but apparently I might have a data structure error here, because I'm not getting the data I want returned.
When I run the first method that I listed:
MarketDataListLevel2 a = getDepthMarketData(coin);
When I debug this 'a' object, I see that each element in the listofmarketdatalists array is 'null' instead of containing an object with this format: {"Bid":{"Price":10.0,"Size":2.0,"ExchangeID":"SMART","timeStamp":0}, "Ask":{"Price":12.0,"Size":2.0,"ExchangeID":"SMART","timeStamp":0}}.
Any advice would be awesome.