1.获取字符串:
private String getAssest() { StringBuffer result = new StringBuffer(); String line = ""; try { InputStreamReader inputStreamReader = new InputStreamReader(getResources().getAssets().open("json.txt")); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); while ((line = bufferedReader.readLine()) != null) { result.append(line); } bufferedReader.close(); inputStreamReader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result.toString(); }
2.测试
private void testJSon() throws JSONException { try { String json = new JSONStringer().object().key("name").value("chen").key("age").value(18).endObject().toString(); Log.i("W", "JSON: " + json); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } JSONArray jsonArrayList = new JSONArray(); JSONObject member1 = new JSONObject(); member1.put("name", "a"); member1.put("age", 18); member1.put("sex", "man"); jsonArrayList.put(member1); String test_json = getAssest(); test_json = "{\"test\":" + test_json + "}"; JSONObject jsonObject; try { jsonObject = new JSONObject(test_json); JSONArray jsonArray = jsonObject.getJSONArray("test"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject temp = (JSONObject) jsonArray.get(i); String date = temp.getString("date"); String open = temp.getString("open"); Log.i("W", "date: " + date + ", open: " + open); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
相关推荐
java json api,json api
该压缩包包含json使用到的所有jar,jar版本如下: commons-beanutils-1.9.2.jar,commons-collections-3.2.1.jar,commons-lang-2.6.jar, commons-logging-1.1.1.jar,ezmorph-1.0.6.jar,json-lib-2.4-jdk15.jar ...
java json map arraylist 转换 json jar包
JsonPath 是java Json库,最新源代码JsonPath 是java Json库,最新源代码JsonPath 是java Json库,最新源代码JsonPath 是java Json库,最新源代码JsonPath 是java Json库,最新源代码JsonPath 是java Json库,最新源...
Java json开发文档以及示例和jar文件
eclipse中使用json相关的jar包,比较全,有gson相关的。
java json依赖包(完整直接可用版),一键导入。内含json-lib, commons, ezmorph等库。
里面包含所有java 使用json所需要的jar包,包含json-lib-2.4-jdk15,ezmorph-1.0.6,commons-logging-1.1.1,commons-lang-2.5,commons-beanutils-1.8.0,commons-collections-3.2.1
关于java json解析的简单测试,简单示例
java json所依赖的所有jar包(json.jar.rar) java json所依赖的所有jar包(json.jar.rar) java json所依赖的所有jar包(json.jar.rar)
java json demo java json demo java json demo
Java Json序列化与反序列化
java使用json的工具包
处理json、的java lib 使用见:www.json.org
JAVA JSON 包,同时把这几个包放进去引用就可
Java Json 必需的jia包。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。...
json jsonjsp工具 jspjsonjar包 java 转化成json数据格式 JSONArray,
用于解析Java JSON,里面的包有不少是根据链接收集的,但发现仍然不能完整执行。 经检查还是缺少commons-collections-3.2.1.jar这个包(过高的版本,如4.5不支持Json Lib)。 包名录如下: json-lib-2.2-jdk15.jar ...
使用JSON-LIB转换JAVA对象(转载) jave对象转json json字符串转java对象demo 下载直接导入Eclipse
JAVA使用 json必须用到的jar包 否则JSONObject.fromObject 报错