将String转换为JSONArray

时间:2017-09-22 09:27:44

标签: java json

我检查过JSON是否有效。该网站说有效。

my JSon

这是我的JSON功能。 我编辑了这样的函数:

public static JSONArray getJSONfromURL(String url) {
        InputStream is = null;
        String result = "";
        JSONArray jArray = null;

        // Download JSON data from URL
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpGet get = new HttpGet(url);
            HttpResponse response = httpclient.execute(get);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();

        } catch (Exception e) {
            Log.e("log_tag", "Error in http connection " + e.toString());
        }

        // Convert response to string
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
               System.out.println("sb"+sb);
            is.close();
            result = sb.toString();

        } catch (Exception e) {
            Log.e("log_tag", "Error converting result " + e.toString());
        }
        JSONArray myArray = null;
        result = result.replaceAll("^\"|\"$", "");
        StringEscapeUtils.unescapeJava(result);

        try {
            myArray = new JSONArray(result);System.out.println(myArray.get(0));
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return myArray;
    }
}

在我的函数中jArray为空。 result与我的JSON相同。如何将string转换为JSONArray。我的json文件看起来像这样: json

"[{\"Id\":1005,\"Sehir_id\":\"1\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane\",\"Aciklama\":\"deneme hastane1\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1007,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane3\",\"Aciklama\":\"deneme hastane3\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1008,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane4\",\"Aciklama\":\"deneme hastane4\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1009,\"Sehir_id\":\"3\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeyetest hastane\",\"Aciklama\":\"Luckyeyetest hastane\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1010,\"Sehir_id\":\"4\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeye hastanee\",\"Aciklama\":\"Luckyeye hastanee\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1011,\"Sehir_id\":\"12\",\"Ilceid\":\"\",\"Hastaneadi\":\"test\",\"Aciklama\":\"test\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1012,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"İstanbul Test Hastanesi\",\"Aciklama\":\"İstanbul Test Hastanesi\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1013,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"AMERİKAN HASTANESİ (NİŞANTAŞI )\",\"Aciklama\":\"AMERİKAN HASTANESİ (NİŞANTAŞI )\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1014,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (KADIKÖY)\",\"Aciklama\":\"ACIBADEM HASTANESİ (KADIKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1015,\"Sehir_id\":\"8\",\"Ilceid\":\"23\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (MASLAK)\",\"Aciklama\":\"ACIBADEM HASTANESİ (MASLAK)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1016,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (FULYA)\",\"Aciklama\":\"ACIBADEM HASTANESİ (FULYA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1017,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (BAKIRKÖY)\",\"Aciklama\":\"ACIBADEM HASTANESİ (BAKIRKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1018,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (KOZYATAĞI)\",\"Aciklama\":\"ACIBADEM HASTANESİ (KOZYATAĞI)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1019,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"KADIKÖY ŞİFA HASTANESİ (KADIKÖY)\",\"Aciklama\":\"KADIKÖY ŞİFA HASTANESİ (KADIKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1020,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"FLORENCE NİGHTİNGALE (GAYRETTEPE)\",\"Aciklama\":\"FLORENCE NİGHTİNGALE (GAYRETTEPE)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1021,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"FLORENCE NİGHTİNGALE (ÇAĞLAYAN)\",\"Aciklama\":\"FLORENCE NİGHTİNGALE (ÇAĞLAYAN)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1022,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"MEMORİAL HASTANESİ (ŞİŞLİ)\",\"Aciklama\":\"MEMORİAL HASTANESİ (ŞİŞLİ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1023,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"MEMORİAL HASTANESİ (ATAŞEHİR)\",\"Aciklama\":\"MEMORİAL HASTANESİ (ATAŞEHİR)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1024,\"Sehir_id\":\"15\",\"Ilceid\":\"49\",\"Hastaneadi\":\"EGE ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Aciklama\":\"EGE ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1025,\"Sehir_id\":\"15\",\"Ilceid\":\"50\",\"Hastaneadi\":\"9 EYLÜL ÜNİVERSİTESİ HASTANESİ (İNCİRALTI )\",\"Aciklama\":\"9 EYLÜL ÜNİVERSİTESİ HASTANESİ (İNCİRALTI )\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1026,\"Sehir_id\":\"15\",\"Ilceid\":\"\",\"Hastaneadi\":\"ŞİFA ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Aciklama\":\"ŞİFA ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1027,\"Sehir_id\":\"15\",\"Ilceid\":\"45\",\"Hastaneadi\":\"MEDİKAL PARK HASTANESİ (KARŞIYAKA)\",\"Aciklama\":\"MEDİKAL PARK HASTANESİ (KARŞIYAKA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1028,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"ANKARA ÜNİVERSİTESİ İBNİ SİNA HASTANESİ (ALTINDAĞ)\",\"Aciklama\":\"ANKARA ÜNİVERSİTESİ İBNİ SİNA HASTANESİ (ALTINDAĞ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1029,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"HACETTEPE ÜNİVERSİTESİ HASTANESİ (SIHHIYE)\",\"Aciklama\":\"HACETTEPE ÜNİVERSİTESİ HASTANESİ (SIHHIYE)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1030,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"BAYINDIR HASTANESİ (SÖĞÜTGÖZÜ)\",\"Aciklama\":\"BAYINDIR HASTANESİ (SÖĞÜTGÖZÜ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1031,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"T.O.B.B. ETÜ HASTANESİ (SÖĞÜTGÖZÜ)\",\"Aciklama\":\"T.O.B.B. ETÜ HASTANESİ (SÖĞÜTGÖZÜ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1032,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"Haydarpaşa Numune Eğitim Hastanesi\",\"Aciklama\":\"Haydarpaşa Numune Eğitim Hastanesi\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1033,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"GÜNGÖREN KOLAN HASTANESİ\",\"Aciklama\":\"GÜNGÖREN KOLAN HASTANESİ\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1034,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"KOLAN HASTANESİ (GÜNGÖREN)\",\"Aciklama\":\"KOLAN HASTANESİ (GÜNGÖREN)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1036,\"Sehir_id\":\"1\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane\",\"Aciklama\":\"asdasd\",\"Siralama\":2,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1037,\"Sehir_id\":\"15\",\"Ilceid\":\"49\",\"Hastaneadi\":\"TEST BORNOVA HASTANE\",\"Aciklama\":\"asd\",\"Siralama\":3,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false}]"

sb的输出是

sb:"[{\"Id\":1005,\"Sehir_id\":\"1\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane\",\"Aciklama\":\"deneme hastane1\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1007,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane3\",\"Aciklama\":\"deneme hastane3\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1008,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane4\",\"Aciklama\":\"deneme hastane4\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1009,\"Sehir_id\":\"3\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeyetest hastane\",\"Aciklama\":\"Luckyeyetest hastane\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1010,\"Sehir_id\":\"4\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeye hastanee\",\"Aciklama\":\"Luckyeye hastanee\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1011,\"Sehir_id\":\"12\",\"Ilceid\":\"\",\"Hastaneadi\":\"test\",\"Aciklama\":\"test\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1012,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"Ä°stanbul Test Hastanesi\",\"Aciklama\":\"Ä°stanbul Test Hastanesi\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1013,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"AMERÄ°KAN HASTANESÄ° (NÄ°ÅANTAÅI )\",\"Aciklama\":\"AMERÄ°KAN HASTANESÄ° (NÄ°ÅANTAÅI )\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1014,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESÄ° (KADIKÃY)\",\"Aciklama\":\"ACIBADEM HASTANESÄ° (KADIKÃY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1015,\"Sehir_id\":\"8\",\"Ilceid\":\"23\",\"Hastaneadi\":\"ACIBADEM HASTANESÄ° (MASLAK)\",\"Aciklama\":\"ACIBADEM HASTANESÄ° (MASLAK)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1016,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESÄ° (FULYA)\",\"Aciklama\":\"ACIBADEM HASTANESÄ° (FULYA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\

2 个答案:

答案 0 :(得分:0)

从它的外观尝试使用,

您可以验证您的JSON here。从JSON中删除转义字符也是明智的选择。

链接到org.apache.commons.lang.StringEscapeUtils jar

String test = "\"[{\"Id\":1005,\"Sehir_id\":\"1\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane\",\"Aciklama\":\"deneme hastane1\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1007,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane3\",\"Aciklama\":\"deneme hastane3\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1008,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane4\",\"Aciklama\":\"deneme hastane4\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1009,\"Sehir_id\":\"3\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeyetest hastane\",\"Aciklama\":\"Luckyeyetest hastane\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1010,\"Sehir_id\":\"4\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeye hastanee\",\"Aciklama\":\"Luckyeye hastanee\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1011,\"Sehir_id\":\"12\",\"Ilceid\":\"\",\"Hastaneadi\":\"test\",\"Aciklama\":\"test\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1012,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"İstanbul Test Hastanesi\",\"Aciklama\":\"İstanbul Test Hastanesi\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1013,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"AMERİKAN HASTANESİ (NİŞANTAŞI )\",\"Aciklama\":\"AMERİKAN HASTANESİ (NİŞANTAŞI )\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1014,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (KADIKÖY)\",\"Aciklama\":\"ACIBADEM HASTANESİ (KADIKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1015,\"Sehir_id\":\"8\",\"Ilceid\":\"23\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (MASLAK)\",\"Aciklama\":\"ACIBADEM HASTANESİ (MASLAK)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1016,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (FULYA)\",\"Aciklama\":\"ACIBADEM HASTANESİ (FULYA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1017,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (BAKIRKÖY)\",\"Aciklama\":\"ACIBADEM HASTANESİ (BAKIRKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1018,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (KOZYATAĞI)\",\"Aciklama\":\"ACIBADEM HASTANESİ (KOZYATAĞI)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1019,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"KADIKÖY ŞİFA HASTANESİ (KADIKÖY)\",\"Aciklama\":\"KADIKÖY ŞİFA HASTANESİ (KADIKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1020,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"FLORENCE NİGHTİNGALE (GAYRETTEPE)\",\"Aciklama\":\"FLORENCE NİGHTİNGALE (GAYRETTEPE)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1021,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"FLORENCE NİGHTİNGALE (ÇAĞLAYAN)\",\"Aciklama\":\"FLORENCE NİGHTİNGALE (ÇAĞLAYAN)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1022,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"MEMORİAL HASTANESİ (ŞİŞLİ)\",\"Aciklama\":\"MEMORİAL HASTANESİ (ŞİŞLİ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1023,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"MEMORİAL HASTANESİ (ATAŞEHİR)\",\"Aciklama\":\"MEMORİAL HASTANESİ (ATAŞEHİR)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1024,\"Sehir_id\":\"15\",\"Ilceid\":\"49\",\"Hastaneadi\":\"EGE ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Aciklama\":\"EGE ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1025,\"Sehir_id\":\"15\",\"Ilceid\":\"50\",\"Hastaneadi\":\"9 EYLÜL ÜNİVERSİTESİ HASTANESİ (İNCİRALTI )\",\"Aciklama\":\"9 EYLÜL ÜNİVERSİTESİ HASTANESİ (İNCİRALTI )\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1026,\"Sehir_id\":\"15\",\"Ilceid\":\"\",\"Hastaneadi\":\"ŞİFA ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Aciklama\":\"ŞİFA ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1027,\"Sehir_id\":\"15\",\"Ilceid\":\"45\",\"Hastaneadi\":\"MEDİKAL PARK HASTANESİ (KARŞIYAKA)\",\"Aciklama\":\"MEDİKAL PARK HASTANESİ (KARŞIYAKA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1028,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"ANKARA ÜNİVERSİTESİ İBNİ SİNA HASTANESİ (ALTINDAĞ)\",\"Aciklama\":\"ANKARA ÜNİVERSİTESİ İBNİ SİNA HASTANESİ (ALTINDAĞ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1029,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"HACETTEPE ÜNİVERSİTESİ HASTANESİ (SIHHIYE)\",\"Aciklama\":\"HACETTEPE ÜNİVERSİTESİ HASTANESİ (SIHHIYE)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1030,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"BAYINDIR HASTANESİ (SÖĞÜTGÖZÜ)\",\"Aciklama\":\"BAYINDIR HASTANESİ (SÖĞÜTGÖZÜ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1031,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"T.O.B.B. ETÜ HASTANESİ (SÖĞÜTGÖZÜ)\",\"Aciklama\":\"T.O.B.B. ETÜ HASTANESİ (SÖĞÜTGÖZÜ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1032,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"Haydarpaşa Numune Eğitim Hastanesi\",\"Aciklama\":\"Haydarpaşa Numune Eğitim Hastanesi\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1033,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"GÜNGÖREN KOLAN HASTANESİ\",\"Aciklama\":\"GÜNGÖREN KOLAN HASTANESİ\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1034,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"KOLAN HASTANESİ (GÜNGÖREN)\",\"Aciklama\":\"KOLAN HASTANESİ (GÜNGÖREN)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1036,\"Sehir_id\":\"1\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane\",\"Aciklama\":\"asdasd\",\"Siralama\":2,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1037,\"Sehir_id\":\"15\",\"Ilceid\":\"49\",\"Hastaneadi\":\"TEST BORNOVA HASTANE\",\"Aciklama\":\"asd\",\"Siralama\":3,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false}]\"";
test = test.replaceAll("^\"|\"$", "");
StringEscapeUtils.unescapeJava(test);
JSONArray myArray = new JSONArray(test);
System.out.println(myArray.get(0));

更新

result = result.replaceAll("^\"|\"$", ""); 
StringEscapeUtils.unescapeJava(result);
JSONArray myArray = new JSONArray(result);
System.out.println(myArray.get(0));

答案 1 :(得分:0)

您可以使用String内容实例化JSONArray,例如:

String string = "[{\"Id\":1005,\"Sehir_id\":\"1\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane\",\"Aciklama\":\"deneme hastane1\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1007,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane3\",\"Aciklama\":\"deneme hastane3\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1008,\"Sehir_id\":\"10\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane4\",\"Aciklama\":\"deneme hastane4\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1009,\"Sehir_id\":\"3\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeyetest hastane\",\"Aciklama\":\"Luckyeyetest hastane\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1010,\"Sehir_id\":\"4\",\"Ilceid\":\"\",\"Hastaneadi\":\"Luckyeye hastanee\",\"Aciklama\":\"Luckyeye hastanee\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1011,\"Sehir_id\":\"12\",\"Ilceid\":\"\",\"Hastaneadi\":\"test\",\"Aciklama\":\"test\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1012,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"İstanbul Test Hastanesi\",\"Aciklama\":\"İstanbul Test Hastanesi\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1013,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"AMERİKAN HASTANESİ (NİŞANTAŞI )\",\"Aciklama\":\"AMERİKAN HASTANESİ (NİŞANTAŞI )\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1014,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (KADIKÖY)\",\"Aciklama\":\"ACIBADEM HASTANESİ (KADIKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1015,\"Sehir_id\":\"8\",\"Ilceid\":\"23\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (MASLAK)\",\"Aciklama\":\"ACIBADEM HASTANESİ (MASLAK)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1016,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (FULYA)\",\"Aciklama\":\"ACIBADEM HASTANESİ (FULYA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1017,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (BAKIRKÖY)\",\"Aciklama\":\"ACIBADEM HASTANESİ (BAKIRKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1018,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"ACIBADEM HASTANESİ (KOZYATAĞI)\",\"Aciklama\":\"ACIBADEM HASTANESİ (KOZYATAĞI)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1019,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"KADIKÖY ŞİFA HASTANESİ (KADIKÖY)\",\"Aciklama\":\"KADIKÖY ŞİFA HASTANESİ (KADIKÖY)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1020,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"FLORENCE NİGHTİNGALE (GAYRETTEPE)\",\"Aciklama\":\"FLORENCE NİGHTİNGALE (GAYRETTEPE)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1021,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"FLORENCE NİGHTİNGALE (ÇAĞLAYAN)\",\"Aciklama\":\"FLORENCE NİGHTİNGALE (ÇAĞLAYAN)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1022,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"MEMORİAL HASTANESİ (ŞİŞLİ)\",\"Aciklama\":\"MEMORİAL HASTANESİ (ŞİŞLİ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1023,\"Sehir_id\":\"8\",\"Ilceid\":\"\",\"Hastaneadi\":\"MEMORİAL HASTANESİ (ATAŞEHİR)\",\"Aciklama\":\"MEMORİAL HASTANESİ (ATAŞEHİR)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1024,\"Sehir_id\":\"15\",\"Ilceid\":\"49\",\"Hastaneadi\":\"EGE ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Aciklama\":\"EGE ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1025,\"Sehir_id\":\"15\",\"Ilceid\":\"50\",\"Hastaneadi\":\"9 EYLÜL ÜNİVERSİTESİ HASTANESİ (İNCİRALTI )\",\"Aciklama\":\"9 EYLÜL ÜNİVERSİTESİ HASTANESİ (İNCİRALTI )\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1026,\"Sehir_id\":\"15\",\"Ilceid\":\"\",\"Hastaneadi\":\"ŞİFA ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Aciklama\":\"ŞİFA ÜNİVERSİTESİ HASTANESİ (BORNOVA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1027,\"Sehir_id\":\"15\",\"Ilceid\":\"45\",\"Hastaneadi\":\"MEDİKAL PARK HASTANESİ (KARŞIYAKA)\",\"Aciklama\":\"MEDİKAL PARK HASTANESİ (KARŞIYAKA)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1028,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"ANKARA ÜNİVERSİTESİ İBNİ SİNA HASTANESİ (ALTINDAĞ)\",\"Aciklama\":\"ANKARA ÜNİVERSİTESİ İBNİ SİNA HASTANESİ (ALTINDAĞ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1029,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"HACETTEPE ÜNİVERSİTESİ HASTANESİ (SIHHIYE)\",\"Aciklama\":\"HACETTEPE ÜNİVERSİTESİ HASTANESİ (SIHHIYE)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1030,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"BAYINDIR HASTANESİ (SÖĞÜTGÖZÜ)\",\"Aciklama\":\"BAYINDIR HASTANESİ (SÖĞÜTGÖZÜ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1031,\"Sehir_id\":\"2\",\"Ilceid\":\"\",\"Hastaneadi\":\"T.O.B.B. ETÜ HASTANESİ (SÖĞÜTGÖZÜ)\",\"Aciklama\":\"T.O.B.B. ETÜ HASTANESİ (SÖĞÜTGÖZÜ)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1032,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"Haydarpaşa Numune Eğitim Hastanesi\",\"Aciklama\":\"Haydarpaşa Numune Eğitim Hastanesi\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1033,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"GÜNGÖREN KOLAN HASTANESİ\",\"Aciklama\":\"GÜNGÖREN KOLAN HASTANESİ\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1034,\"Sehir_id\":\"8\",\"Ilceid\":\"1\",\"Hastaneadi\":\"KOLAN HASTANESİ (GÜNGÖREN)\",\"Aciklama\":\"KOLAN HASTANESİ (GÜNGÖREN)\",\"Siralama\":1,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1036,\"Sehir_id\":\"1\",\"Ilceid\":\"\",\"Hastaneadi\":\"deneme hastane\",\"Aciklama\":\"asdasd\",\"Siralama\":2,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false},{\"Id\":1037,\"Sehir_id\":\"15\",\"Ilceid\":\"49\",\"Hastaneadi\":\"TEST BORNOVA HASTANE\",\"Aciklama\":\"asd\",\"Siralama\":3,\"Minbagis\":null,\"Minsure\":null,\"CreatorUID\":null,\"CreationDate\":\"\\/Date(-62135596800000)\\/\",\"CreatorIP\":null,\"UpdateDate\":\"\\/Date(-62135596800000)\\/\",\"UpdaterUID\":0,\"UpdaterIP\":null,\"Deleted\":false}]";
JSONArray array = new JSONArray(string);
System.out.println(array.length()); 

<强>更新

根据问题编辑,与sb相比,result似乎没有完整内容。 sb字符串终止于UpdaterUID而实际result终止对象和数组,因此在解析sb时失败。

因此,看起来缓冲区没有被刷新或者本身没有完整的内容。我可能会尝试更改方法,将InputStream读入String并查看是否有任何区别,例如像这样的东西:

public String convertStreamToString(java.io.InputStream is) {
    java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
    return s.hasNext() ? s.next() : "";
}

另一次更新

看起来你需要从开头和结尾修剪引号,并从响应字符串中取消引号以使其工作。片段下方工作正常:

URL url = new URL("http://bagistest.tev.org.tr/Hastane.asmx/HastaneListesi");
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(
        new InputStreamReader(
            connection.getInputStream()));
StringBuilder response = new StringBuilder();
String inputLine;

while ((inputLine = in.readLine()) != null) 
    response.append(inputLine);

in.close();
String trimmedResponse = response.toString().substring(1, response.toString().length() - 1);
trimmedResponse = trimmedResponse.replace("\\\"", "\"");
System.out.println(trimmedResponse);
JSONArray array = new JSONArray(trimmedResponse);
System.out.println(array.length());