FastJson Date Formatting and Circular Reference Issues: A Debugging Journey
The article recounts a senior architect's investigation into FastJson's date formatting bug and circular reference handling, detailing version mismatches, GitHub issue tracking, feature flag usage, and lessons for backend developers on avoiding hidden serialization pitfalls.
The author, a senior architect, shares a personal experience with FastJson where a global date format (yyyy-MM-dd HH:mmss) failed to apply locally in a Linux test environment, causing timestamps to retain time components.
After local tests passed, the issue surfaced in production due to differing FastJson versions; the test environment used version 1.2.53 while the development environment used a newer version, leading to the bug.
Investigation of the FastJson source revealed the problem was tracked in several GitHub issues (e.g., #1868) and fixed in version 1.2.72, highlighting gaps in test coverage and reliance on core contributors.
The article also discusses FastJson’s circular reference detection, showing how identical objects in different lists can trigger unwanted $ref entries, and recommends disabling this feature via SerializerFeature.DisableCircularReferenceDetect when appropriate.
Additional FastJson features such as WriteMapNullValue and WriteNullListAsEmpty are examined, emphasizing that default enabled behaviors can cause unexpected production failures and should be configurable by users.
Finally, the author reflects on the maintenance challenges of FastJson, the migration to FastJson2, and the importance of consulting open‑source issue trackers to avoid similar pitfalls.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
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.