alibaba / alibaba/fastjson2

JSON.toJSON(Object object, JSONWriter.Feature... features)转JSONObject的时候,如果对象里面有List, 内部递归JSON.toJSON的时候features不会传递

Open
#2,886 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

比如: JSONObject newData = (JSONObject)JSON.toJSON(data,Feature.WriteNulls);
当data对象中有List的时候,List中的空值依旧不会写入到JSONObject 中,从源码中看是因为ObjectWriterAdapter.toJSONObject(T object, long features)方法中在递归调用JSON.toJSON(item)的时候,没有传递Feature.WriteNulls

Contributor guide

Open the contributing guide

Research direction

Start in ObjectWriterAdapter.toJSONObject(T object, long features), then trace its recursive JSON.toJSON(item) call for objects containing a List. Done means Feature.WriteNulls is preserved during nested conversion so null values inside the List appear in the resulting JSONObject.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.