zoukankan      html  css  js  c++  java
  • Java Json

            //list 转 json 数据
    //        List<Object> list = new ArrayList<Object>();
    //        list.add("zhangsan");
    //        list.add(0.34f);
    //        JSONArray jsonArray = JSONArray.fromObject(list);
    //        System.out.println(jsonArray.toString());
            
            //map 转 json 数据
            Map<String,Object> map = new HashMap<String,Object>();
            map.put("name", "张三");
            map.put("sex", "");
            JSONArray jsonArray = JSONArray.fromObject(map);
            System.out.println(jsonArray.toString());
            JSONObject jsonObject = JSONObject.fromObject(map);
            System.out.println(jsonObject.toString());
            
    //        JsonUnit bean = new JsonUnit("zzd","man",30);
    //        JSONArray jsonArray = JSONArray.fromObject(bean);
    //        System.out.println(jsonArray.toString());
    //        JSONObject jsonObject = JSONObject.fromObject(bean);
    //        System.out.println(jsonObject.toString());

    json-lib-2.2.3.jar

    [{"sex":"男","name":"张三"}]
    {"sex":"男","name":"张三"}

  • 相关阅读:
    转码解码问题
    时间问题
    弹框
    获取地址栏参数
    vue返回上一页面如果没有上一页面返回首页
    html知识点
    传统的事件类型
    vue的指令
    事件取消
    事件处理程序
  • 原文地址:https://www.cnblogs.com/leonkobe/p/5362804.html
Copyright © 2011-2022 走看看