In Java project I used WebSocket to get subscription and I get many different responses from socket as JSONArray
, the one which I need looks as below:
[
68,
"te",
[
80588348,
1508768162000,
0.01569882,
5700.8
]
]
How should look JAVA
object for this response?
How can I convert it to this object?
[
68, <- Integer
"te", <- String
[
80588348, <- Long
1508768162000, <- Long
0.01569882, <- Double
5700.8 <- Double
]
]
There is one problem that there are other responses like:
{"event":"subscribed","channel":"trades","chanId":68,"symbol":"tBTCUSD","pair":"BTCUSD"}
And when I try convert it by new JSONArray(response)
it throws org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1].
How to get and convert this fields which I need(the first response example) ?
I want get something like this:
public class Details{
public Long id;
public Long timestamp;
public Double amount;
public Double price;
}
public class Response{
public Integer id;
public String type;
public Details details;
}