西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
西西首頁 電腦軟件 安卓軟件 電腦游戲 安卓游戲 排行榜 專題合集

org.json的包

  • org.json的包
  • 軟件大小:41KB
  • 更新時間:2013-08-01 15:35
  • 軟件語言:中文
  • 軟件廠商:
  • 軟件類別:國產(chǎn)軟件 / 免費軟件 / 編程輔助
  • 軟件等級:2級
  • 應用平臺:WinAll, WinXP
  • 官方網(wǎng)站:暫無
  • 應用備案:
好評:50%
壞評:50%

軟件介紹

如果所創(chuàng)建的JAVA項目不包含JSONObject或者是JSONArray這2個對象, 可以通過添加該jar文件來實現(xiàn).

操作org.json包:

首先導入org.json下面的包

package com.sun;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Test {

public static void main(String args[]) throws JSONException {
String jsonContent = "{'hello':world,'abc':'xyz'}";
JSONObject jsonObject = new JSONObject(jsonContent);
String str1 = jsonObject.getString("hello");
String str2 = jsonObject.getString("abc");
System.out.println(str1);
System.out.println(str2);

System.out.println("------------------");
jsonContent = "[{'hello':333,'abc':'false','xyz':{'a':1,'b':'ab'}},{'hello':555,'abc':'true','xyz':{'a':2,'b':'ba'}}]";
JSONArray jsonArray = new JSONArray(jsonContent);
for(int i=0;i<jsonArray.length();i++){
JSONObject jsonobject2=jsonArray.getJSONObject(i);
int value1=jsonobject2.getInt("hello");
boolean value2=jsonobject2.getBoolean("abc");
// String value3=jsonobject2.getString("xyz");
JSONObject jsonobject3=jsonobject2.getJSONObject("xyz");
int value4=jsonobject3.getInt("a");
String value5=jsonobject3.getString("b");
System.out.println(value1);
System.out.println(value2);
System.out.println(value4);
System.out.println(value5);

}

}
}
輸出結(jié)果
world
xyz
------------------
333
false
1
ab
555
true
2
ba

json正則表達式定義


Json 的基本文法是鍵值對,Key:Value 通過冒號分隔

key類型就是字符串 “key1“, ”key2“。。。

關(guān)鍵是值類型,json定義了7種值類型:

1) 字符串,2) 數(shù)值,3) true, 4) false, 5) null, 甚至 6) 數(shù)組和 7) 對象 都可以是值類型。
軟件標簽: org

軟件截圖

org.json的包

其他版本下載

發(fā)表評論

昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
查看所有(0)條評論 > 字數(shù): 0/500

TOP
軟件下載