zoukankan      html  css  js  c++  java
  • JSONObject和JSONArray

    1:JSON格式数据如下

    {"ticketInfos":[{"name":"刚刚","menPiaoType":"免费门票","price":0},{"name":"刚刚","menPiaoType":"免费门票","price":0}]}

    if (etc.getTicketDetailJson() != null && "".equals(etc.getTicketDetailJson())) {
    	JSONObject myJsonObject = new JSONObject(etc.getTicketDetailJson());
    	JSONArray jsonarry = (JSONArray) myJsonObject.get("ticketInfos");
    	for (int i = 0; i < jsonarry.length(); i++) {
    	TicketDetail ticketDetail = new TicketDetail();
    	JSONObject jObject = (JSONObject) jsonarry.get(i);
    	ticketDetail.setName(jObject.get("name").toString());
    	ticketDetail.setMenPiaoType(jObject.getString("menPiaoType").toString());
    						 
    	price = Integer.parseInt(jObject.get("price").toString());
    	break;
    		}
    }
    

      

  • 相关阅读:
    javase 超市库存系统
    Javase 简单代码练习
    Javase 简单练习
    SQL表连接查询
    SQL多表查询
    SQL表查询
    SQL数据查询2
    SQL数据查询
    SQL增删改
    AutoCompleteTextView的使用
  • 原文地址:https://www.cnblogs.com/SHMILYHP/p/5892712.html
Copyright © 2011-2022 走看看