zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    ubuntu故障处理
    最全http状态码
    go故障排查集锦
    docker知识11---docker service
    docker知识10---docker secret
    windows安装mysql
    信息收集
    模块
    Django:中间件
    Django:ORM单表操作
  • 原文地址:https://www.cnblogs.com/yangly/p/6005918.html
Copyright © 2011-2022 走看看