-1

I want to convert my JSON string to object java in android studio. how should I do

I use android studio

     RequestQueue queue = Volley.newRequestQueue(this);
    String url = "http://orderkilat.co.id/api/kepuasan/persensangatpuasperdata.php";
    JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {

            sangatpuasperdata.setText(response.toString());

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {


        }
    });

    queue.add(jsObjRequest);

i expect the result is without {}.

MurugananthamS
  • 2,395
  • 4
  • 20
  • 49
  • 6
    Possible duplicate of [How to convert the following json string to java object?](https://stackoverflow.com/questions/10308452/how-to-convert-the-following-json-string-to-java-object) – majid ghafouri Oct 21 '19 at 05:39
  • I think your question is very common here, please search related posts first and you are supposed to find the answer! – LHCHIN Oct 21 '19 at 06:23

2 Answers2

0

I recommend you to use JSONObject object to retrieve the data, it allows you to build a new object using a String as a parameter. Check out the API docs: https://developer.android.com/reference/org/json/JSONObject.html#JSONObject(java.lang.String)

0

Try this:

JSONObject responseObject = new JSONObject(response);

JSONObject is inbuilt. You can log "responseObject" and see the result.

Cryogeneye
  • 16
  • 1