zoukankan      html  css  js  c++  java
  • 关于json解析和所需jar

    以解析字符串数组为例: String parameter= [{"id":"pdTNKcY1YS55oG2M",.......}]

    1. 关于net.sf.json(这个jar,需要两个附加jar:commons-jexl-2.1.1.jar、ezmorph-1.0.3.jar)

    JSONArray jsonArray = JSONArray.fromObject(parameter);

    String id= jsonArray.getJSONObject(0).get("id");  

    2. 关于 fastjson

    JSONArray jsonArray = JSON.parseArray(parameter);

    String id = jsonArray.getJSONObject(0).get("id");

    3. 关于 gson (gson解析数据成现有对象比较好,如果没有对应实体,不如上面两个好用)

    String student="{"name":"tom","age":12}";

    Strudent stu=new Gson().fromJson(student,student.class);

    http://kunkun39.iteye.com/blog/2096737

  • 相关阅读:
    02-cocoapods的安装和使用
    01-唐巧之cocoapods
    class0513(html)
    程序集
    c#面向对象
    html
    dom
    Javascript
    Jquery
    ado.net
  • 原文地址:https://www.cnblogs.com/pjlhf/p/8796200.html
Copyright © 2011-2022 走看看