##maven
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.7</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.4</version> </dependency>
##获取unknown字段
JSONObject jsonObj = JSON.parSEObject(json); List<Field> fields = FieldUtils.getAllFieldsList(Demo.class); fields.stream().forEach(e -> { jsonObj.remove(e.getName()); }); System.out.println(jsonObj);原文链接:https://www.f2er.com/json/289017.html