fastjson獲取unknown的字段

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);
相關文章
相關標籤/搜索