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);