<!-- json jar包 --> <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.9.2</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>net.sf.ezmorph</groupId> <artifactId>ezmorph</artifactId> <version>1.0.6</version> </dependency>
//排除roles属性不做序列化 JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setExcludes(new String[]{ "roles" }); //注意,如果json对象包含了为null的值,转换将会报错 JSONObject.fromObject(json, jsonConfig);
时间: 2024-11-08 19:04:09