跳到主要内容
版本:dev

Fory JSON

Fory JSON is Apache Fory's thread-safe Java JSON codec. It provides interpreted and runtime-generated codecs for Java objects, records, immutable creator-based classes, common JDK types, generic containers, custom complete-value codecs, and finite annotation-declared polymorphism.

Fory JSON is a separate data format from Fory's binary native and xlang protocols. Use it when a system must exchange ordinary JSON with browsers, APIs, logs, configuration, or another JSON implementation. Use the Fory binary protocol when you need cross-language schema metadata, reference identity, circular graphs, or Fory's binary-only features.

Documentation map

GoalPage
First runnable JSON round tripGetting Started
Understand Java object mapping and configurationObject Mapping
Configure properties, creators, values, validators, and subtypesAnnotations
Extend complete values, children, and map keysCustom Codecs
Deploy on AndroidAndroid
Build a GraalVM native imageGraalVM Native Image
Decode input safelySecurity
Diagnose failuresTroubleshooting

Limits and unsupported features

Fory JSON intentionally has a smaller semantic surface than the Fory binary protocol and general Jackson object mapping:

  • no shared-reference identity or circular-reference protocol;
  • no open polymorphism, JSON class-name IDs, runtime subtype discovery, or runtime subtype table extension;
  • no InputStream parser or incremental OutputStream writer on the ForyJson root API;
  • no pretty-print configuration;
  • no Jackson/Gson annotation compatibility layer;
  • no aliases, views, filters, injection, managed/back references, object identity annotations, or root wrapping;
  • no Fory core Expose processing.

Circular graphs eventually fail maxDepth; they are not reconstructed. Use Fory core's binary native or xlang protocol when reference identity or cycles are required.

For binary serialization, start with Java Object Serialization and choose xlang or native. Binary builder options are documented separately in Java Configuration.