错误:com.android.volley.ParseError:org.json.JSONException:Value<;!无法将java.lang.String类型的DOCTYPE转换为JSONObject

错误:com.android.volley.ParseError:org.json.JSONException:Value<;!无法将java.lang.String类型的DOCTYPE转换为JSONObject,android,json,android-volley,android-json,Android,Json,Android Volley,Android Json,Java 试图从URL获取json数组对象,但抛出解析错误 CountriedBean是我的POJO课程。 parse_json只有ListView和 parse_json_视图有4个TextView 谁能帮我一下吗 private List<CountriesBean> cntries= new ArrayList<CountriesBean>(); @Override protected void onCreate(Bundle sav

Java 试图从URL获取json数组对象,但抛出解析错误
CountriedBean是我的POJO课程。
parse_json只有ListView和 parse_json_视图有4个TextView

谁能帮我一下吗

private List<CountriesBean> cntries= new ArrayList<CountriesBean>();
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.parse_json);

            RequestQueue queues = Volley.newRequestQueue(JsonParse.this);

            JsonObjectRequest myRequest = new JsonObjectRequest(Request.Method.GET,
                    "https://github.com/SaiNitesh/REST-Web-services/blob/master/RESTfulWS/json_file.json",
                    null,
                    new Response.Listener<JSONObject>() {
                        @Override
                        public void onResponse(JSONObject response) {
                            try{
                                Log.i("myCountries**", "response:" +response);
                            JSONArray countryItems = response.getJSONArray("countryItems");

                            Log.i("myTagx", "response:" +countryItems);

                                for(int i=0; i<countryItems.length();i++){
                                    JSONObject temp= countryItems.getJSONObject(i);

                                    String nm = temp.getString("nm");
                                    String cty = temp.getString("cty");
                                    String hse = temp.getString("hse");
                                    String yrs = temp.getString("yrs");

                                    cntries.add(new CountriesBean(nm, cty, hse, yrs));
                                }
                            } catch(JSONException e){
                                Log.i("myTag",e.toString());
                            }
                        }
                    }, new Response.ErrorListener(){
                @Override
                public void onErrorResponse(VolleyError error){
                    Log.i("myTag", "Error:"+error.toString());
                }
            });

            queues.add(myRequest);

            ArrayAdapter<CountriesBean> adapter=new customAdapter();

            ListView myFirstListView = (ListView) (findViewById(R.id.myCountriesView));
            myFirstListView.setAdapter(adapter);


            myFirstListView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
                //WebView myListViewbrowser = (WebView) findViewById(R.id.myListViewbrowser);
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    Toast.makeText(JsonParse.this,"My List View Item",Toast.LENGTH_SHORT).show();
                }
            });


        }

        private class customAdapter extends ArrayAdapter<CountriesBean>{
            public customAdapter() {
                super(JsonParse.this, R.layout.parse_json_view, cntries);

            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {

                /*getView method is like "for loop"
                For First time convertView=null, then it gets 1st list, then it returns(return convertView) the first list,
                then the convertView will be null
                After that it starts from here again for 2nd list and it continues*/
                if(convertView == null){
                    convertView = getLayoutInflater().inflate(R.layout.parse_json_view, parent,false);

                }


                TextView countryName = (TextView) convertView.findViewById(R.id.name);
                TextView countryCity = (TextView) convertView.findViewById(R.id.city);
                TextView countryHouse = (TextView) convertView.findViewById(R.id.house);

                CountriesBean myCurrentctries = cntries.get(position);


                countryName.setText(myCurrentctries.getNm());
                countryCity.setText(myCurrentctries.getCty());
                countryHouse.setText( myCurrentctries.getHse() );

                return convertView;
            }


        }
private List cntries=new ArrayList();
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.parse_json);
RequestQueue queues=Volley.newRequestQueue(JsonParse.this);
JsonObjectRequest myRequest=新的JsonObjectRequest(Request.Method.GET,
"https://github.com/SaiNitesh/REST-Web-services/blob/master/RESTfulWS/json_file.json",
无效的
新的Response.Listener(){
@凌驾
公共void onResponse(JSONObject响应){
试一试{
Log.i(“myCountries**”,“response:+response”);
JSONArray countryItems=response.getJSONArray(“countryItems”);
Log.i(“myTagx”,“响应:+countryItems”);

对于(inti=0;iurl
https://github.com/SaiNitesh/REST-Web-services/blob/master/RESTfulWS/json_file.json
是一个HTML页面,因此会出现该异常


请使用
https://raw.githubusercontent.com/SaiNitesh/REST-Web-services/master/RESTfulWS/json_file.json
相反。

url的响应
https://github.com/SaiNitesh/REST-Web-services/blob/master/RESTfulWS/json_file.json
是一个HTML页面,因此会出现该异常


请使用
https://raw.githubusercontent.com/SaiNitesh/REST-Web-services/master/RESTfulWS/json_file.json
相反。

请发布错误日志。也请发布错误日志。如果我想像JSON文件一样上传图像,该怎么办?如何将其显示为原始数据?我认为您应该针对您的新需求创建一个新问题,或者您可以n在S.O中搜索fist,有许多可用的链接(其中一个是),但您还需要澄清、下载或上传。如果我想像JSON文件一样上传图像,如何将其显示为原始数据?我认为您应该为您的新需求创建一个新问题,或者您可以在S.O中搜索fist,有许多可用的链接(其中一个是),但您还需要澄清、下载或上传