FastJson Issues: Date Format Priority, $ref Circular Reference, and Lessons Learned
The article recounts a developer's experience with FastJson, detailing a date‑format configuration bug caused by an outdated library version, a $ref circular‑reference serialization issue, the debugging steps taken, and broader observations about FastJson's maintenance and feature defaults.
The author shares a personal investigation into FastJson problems encountered in a Spring Boot project, starting with a date‑format priority issue where a global pattern ( yyyy-MM-dd HH:mmss ) overrode a local annotation, leading to unexpected timestamps in the test environment.
Testing on Windows showed no issue, but on Linux the global configuration persisted; the author simulated Linux via VM options ( -Dos.name=linux ) and remote debugging, eventually discovering that the test environment used FastJson version 1.2.53, older than the fixed version 1.2.72, causing the bug.
References to GitHub issue #1868 and pull request #2706 illustrate that the problem was reported in 2018 and only resolved in 2020, highlighting gaps in test coverage and reliance on a few core contributors.
The second problem involves $ref circular‑reference handling; FastJson treats repeated object references as circular references, which can be disabled with SerializerFeature.DisableCircularReferenceDetect . The author notes that this feature, along with others like WriteMapNullValue and WriteNullListAsEmpty , should give users control rather than being enabled by default.
Overall, the article concludes that FastJson has useful features but suffers from inconsistent maintenance, version‑specific bugs, and default settings that may cause production incidents, recommending careful version management and consideration of FastJson2.
At the end, the author promotes a knowledge‑sharing community and paid resources, asking readers to like, share, and follow for continued content.
Code Ape Tech Column
Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.