Volley : how can I parse data String with integer by HashMap Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Volley : how can I parse data String with integer by HashMap without wasting too much if your time.

The question is published on by Tutorial Guruji team.

how can I parse data String with integer by HashMap I have String and integer data of json and the problem in HashMap he accept just String or integer value this Is structure of Json

   "message":"Get Products Successfully",
         "p_name":"Ford Red",

this is my java code

 final ProgressDialog pDialog = new ProgressDialog(getActivity());

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, "myLink", null,
            new Response.Listener<JSONObject>() {
                public void onResponse(JSONObject response) {

            }, new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {

        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String,String> params = new HashMap<>();
            params.put("p_descrption","mac mac 2018");
            return params;




in my json structure it is a integer , how can I parse this data like a integer value ?


You don’t need to parse anything, rather use JsonObjectRequest as intended.

Which is to move the map from getParams method (and possibly remove the method entirely) and then create your payload ahead of the Volley call

JSONObject payload = new JSONObject();
JSONArray products = new JSONArray();

JSONObject product = new JSONObject();
product.putInt("price", 100);

payload.putArray("products", products);

JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, "myLink", payload,
        new Response.Listener<JSONObject>() {

And if you want to parse the response, you can directly call response.getInt , for example

If you want, you can combine Volley with Gson, as pointed out in the Android documentation, which makes this implementation cleaner, or Retrofit w/ Gson would work similarly

We are here to answer your question about Volley : how can I parse data String with integer by HashMap - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji