當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
json文本装换为JSONArray
生活随笔
收集整理的這篇文章主要介紹了
json文本装换为JSONArray
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 package com.beijxing.TestMain;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import org.apache.commons.io.FileUtils;
7
8 import net.sf.json.JSONArray;
9 import net.sf.json.JSONObject;
10
11 /**
12 * JSON文本轉換為JSONArray
13 * @author 作者 : ywp
14 * @version 創建時間:2016年10月25日 下午10:30:14
15 */
16 public class TestJson4 {
17 public static void main(String[] args) {
18 try {
19 fileToJson();
20 } catch (IOException e) {
21 e.printStackTrace();
22 }
23 }
24 public static void fileToJson() throws IOException{
25 File file = new File(TestJson4.class.getResource("/jsonText2.json").getFile());//獲取項目根路徑下的文件
26 String content = FileUtils.readFileToString(file);
27 //JSONObject jsonObject = JSONObject.fromObject(content);
28 JSONArray jsonArray = JSONArray.fromObject(content);
29 System.out.println("jsonarray:"+jsonArray);
30 }
31 }
?
轉載于:https://www.cnblogs.com/yangly/p/6005918.html
總結
以上是生活随笔為你收集整理的json文本装换为JSONArray的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 标准化知识
- 下一篇: 读书笔记--对象、实例、原型、继承