JSONObject所需要的依赖和简单使用
发布日期:2021-05-15 00:43:14 浏览次数:17 分类:精选文章

本文共 2153 字,大约阅读时间需要 7 分钟。

JSONObject ���������������������������

JSONObject���������������

��������� JSONObject ��������������������������������������������������������������� Zookeeper ��������� JSON Processing Library������������ Java ���������������

  • json-lib

    • GroupId: net.sf.json-lib
    • ArtifactId: json-lib
    • Version: 2.4
    • classifier: jdk15
  • commons-beanutils

    • GroupId: commons-beanutils
    • ArtifactId: commons-beanutils
    • Version: 1.7.0
  • commons-collections

    • GroupId: commons-collections
    • ArtifactId: commons-collections
    • Version: 3.1
  • commons-lang

    • GroupId: commons-lang
    • ArtifactId: commons-lang
    • Version: 2.5
  • ezmorph

    • GroupId: net.sf.ezmorph
    • ArtifactId: ezmorph
    • Version: 1.0.3
  • commons-logging

    • GroupId: commons-logging
    • ArtifactId: commons-logging
    • Version: 1.2
  • JSONObject���������������������

    ���������������

    ������������������������������������������

    package com.entity;
    import lombok.AllArgsConstructor;
    import lombok.Data;
    import lombok.NoArgsConstructor;
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public class TableData {
    private int id;
    private String username;
    private String sex;
    private String city;
    }

    ������������������JSON������

    ���������������������

    public String tableData() {
    TableData tableData = new TableData();
    tableData.setCity("������");
    tableData.setId(1);
    tableData.setUsername("������");
    tableData.setSex("���");
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("tableData", tableData);
    System.out.println(jsonObject.toString());
    return jsonObject.toString();
    }

    ������������

    • ������������������������������������������������������������������������������ json-lib ������

    • ������������������������ Lombok ������������������ JavaBean ������������������������������ getter ��� setter ���������

    • ** JSONObject ���������**��������� new JSONObject() ��������������� JSON ���������

    • ������������ JSON��������� jsonObject.put("tableData", tableData) ������������������ JSON ���������

    • ��������������������� System.out.println(jsonObject.toString()) ��������������������� JSON ������������

    ������������������������������������������ JavaBean ������������������������������ JSON ������������������������������������������

    上一篇:web项目解决出现406的错误
    下一篇:Idea创建web项目访问jsp

    发表评论

    最新留言

    哈哈,博客排版真的漂亮呢~
    [***.90.31.176]2025年04月09日 14时38分23秒

    关于作者

        喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
    -- 愿君每日到此一游!

    推荐文章