收到此错误 org.json.JSONException:java.lang.String 类型 0 处的值无法转换为 JSONObjecton 解析

Getting this error org.json.JSONException: Value at 0 of type java.lang.String cannot be converted to JSONObjecton parsing

我在解析 json 时遇到此错误。谁能帮我解决这个问题。

  {
"website": [
    "http://www.example.com",
    "https://buy.example.com"
],
"number": [
    "4546",
    "54256456"
],
"email": [
    "exam@gmail.com",
    "example@gmail.com"
],
"address": [
    "any adddress here",
    "Address 2"
]
  }

任何人都可以帮助我如何准确解析这个 json...

Json 解析代码

             String JSON_STRING = response.body().string();
                    Log.e("json_string", JSON_STRING.toString());
                    //Toast.makeText( getApplicationContext(), "Response : "+JSON_STRING, Toast.LENGTH_LONG ).show();

                    JSONObject object = new JSONObject( JSON_STRING );
                    JSONArray jsonArray = object.getJSONArray( "website" );

                        for (int i=0; i<jsonArray.length(); i++)
                        {
                            JSONObject website = jsonArray.getJSONObject( i );
                            Log.e("website", website.toString());
                        }
// for email array and response variable is your jsonObject coming from server
JSONArray jsonArray = response.getJSONArray("email")
for(int i = 0; i < jsonArray.length(); i++){
   //get email one by one 
   String email = jsonArray.getString(i)
}

让我知道它是否有效。

试试这个代码

 try {
        JSONObject jsonObject = new JSONObject(json);
        JSONArray websites = jsonObject.getJSONArray("website");
        for (int i = 0; i < websites.length(); i++) {
            Log.d("TAG", websites.getString(i));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }