我知道这个问题已经得到了绝对回答,但我没有找到解决方案。 我从 Web 服务收到一个 Json 字符串响应,即 ["11,22222","33,44444"]。
我尝试了这个但没有成功,因为字符串包含这些字符 [ ] 并且第一个逗号在此处 11,22
StringBuilder result = new StringBuilder();
URL url2 = new URL(url);
HttpURLConnection conn = (HttpURLConnection) url2.openConnection();
conn.setRequestMethod("GET");
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
String res = new String(result);
String [] coordinates = res.split(",");
我怎样才能把这个字符串分开,比如“11,22222”和“33,44444”
最佳答案
只需使用 JavaScriptSerializer。
public void Method(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
List<string> results = js.Deserialize<List<string>>(json);
}
关于arrays - 拆分字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48022831/