Есть String Volley connect.
StringRequest request = new StringRequest(Request.Method.GET,regions, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG,"login response"+ response);
try {
ObjectMapper mapper=new ObjectMapper();
Pojo pojo=mapper.readValue(response,Pojo.class);
System.out.println(pojo.getSuccessPojo());
}catch (IOException e) {
e.printStackTrace();
}
JSON
{
"success": true,
"data": [
{
"id": "1",
"name": "АР Крым"
},
{
"id": "2",
"name": "Винницкая область"
},
Pojo
@JsonIgnoreProperties(ignoreUnknown=true)public class Pojo {
public Pojo(){}
private String success,id;
@JsonProperty("success")
public String getSuccessPojo() {
return success;
}
public void setSuccessPojo(String success) {
this.success = success;
}
Всё работает для "success": true,
, как вытянуть информацию из "data": []
?
success
почемуString
, а неBoolean
?