Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Fast Android Networking

Fast Android Networking JSON Parsing

This is the request

     AndroidNetworking.post("URL")
        .addBodyParameter("auth_token", "abcdefghijkl123")

I am sending a json format query as a parameter

        .addBodyParameter("query","{\n" +
                "\"app_simul_type\": \"sub\",\n" +
                "\"application_status\": \"appraiser_job_acceptance\",\n" +
                "\"appraisal_request.appraiser_username\": 
                \"appraiser@pnbappraisal.com\",\n" +
                "\"system.hidden\": false\n" +
                "}")
        .addBodyParameter("limit", "0")
        .addBodyParameter("only", "{\n" +
                "  \"system.record_id\": {},\n" +
                "  \"app_account_first_name\": {},\n" +
                "  \"app_account_middle_name\": {},\n" +
                "  \"app_account_last_name\": {},\n" +
                "  \"appraisal_request.app_request_appraisal\": {}\n" +
                "}")

             .setPriority(Priority.MEDIUM)
             .build()

             .getAsJSONArray(new JSONArrayRequestListener() {

This is if there is a response

    @Override
    public void onResponse(JSONArray response) {
        // do anything with response

Trying to parse the response and store it in hashmap and then to arraylist

          if (response.toString() != null) {
            try {
                JSONObject jsonObj = new JSONObject(response.toString());

                // Getting JSON Array node
                JSONArray contacts = jsonObj.getJSONArray("records");

                // looping through All Contacts
                for (int i = 0; i < contacts.length(); i++) {
                    JSONObject c = contacts.getJSONObject(i);
                    String id = c.getString("id");
                    String name = c.getString("name");
                    String type = c.getString("type");

                    // tmp hash map for single contact
                    HashMap<String, String> activejobs = new HashMap<>();

                    // adding each child node to HashMap key => value
                    activejobs.put("id", id);
                    activejobs.put("name", name);
                    activejobs.put("type", type);

                    // adding contact to contact list
                    ArrayListactiveJobs.add(activejobs);
                }
            } catch (final JSONException e) {
                e.printStackTrace();
                }

        json.setText((CharSequence) ArrayListactiveJobs);
        Log.d(TAG, "onResponse array : " + response.toString());
        Toast.makeText(getContext(),"Meron"+response.toString(), Toast.LENGTH_LONG).show();
        }}

    @Override
    public void onError(ANError error) {
        // handle error
        json.setText(error.getErrorDetail());

 Toast.makeText(getContext(),"wala"+
error.getErrorDetail()+error.getErrorCode(), 
android.widget.Toast.LENGTH_SHORT).show();
}
   });}}

Any Idea why I am getting parse error? I am using fast android networking and trying to parse without model class and I am trying to send json format query as a parameter. I tried this on the rest client it works fine.

Comments