JsonParse.getListPerson 也不知道咋实现的,
可能出现的问题,比如中文处理不好,用全英文试试。
可能出现的问题,比如中文处理不好,用全英文试试。
解决方案 »
- android画图Surface:lock failed,already locked求助
- 如何判断栈里是否存在一个activity??大牛来帮我啊
- AsyncQueryHandler 空指针的问题
- Unable to open trace file
- 请教一下,如何在Android里面实现该SQLite语句
- 如何在eclipse中新建一个android类
- ksoap2 调用 .net webservice 问题【高分】
- android 谁做过五维图方面的大神?????
- android新浪微博客户端授权问题
- ArcGis 中GraphicsLayer图层新加元素后map怎样更新
- 新人HelloAndroid onCreate 空指针错误
- 请教能否实现fragment内操控其fragmentActivity
整个Json类public class JsonParse { /** * 解析Json数据 * * @param urlPath * @return mlists * @throws Exception */ public static List<Person> getListPerson(String urlPath) throws Exception { List<Person> mlists = new ArrayList<Person>(); byte[] data = readParse(urlPath); JSONArray array = new JSONArray(new String(data)); for (int i = 0; i < array.length(); i++) { JSONObject item = array.getJSONObject(i); String name = item.getString("name"); String address = item.getString("address"); int age = item.getInt("age"); mlists.add(new Person(name, address, age)); } return mlists; } /** * 从指定的url中获取字节数组 * * @param urlPath * @return 字节数组 * @throws Exception */ public static byte[] readParse(String urlPath) throws Exception { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] data = new byte[1024]; int len = 0; URL url = new URL(urlPath); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); InputStream inStream = conn.getInputStream(); while ((len = inStream.read(data)) != -1) { outStream.write(data, 0, len); } inStream.close(); return outStream.toByteArray(); }}还有就是JSON里面都是英文