Skip to content

Releases: jdereg/json-io

4.96.0

01 Mar 14:17

Choose a tag to compare

Highlights

  • 25 annotations for declarative serialization control (@IoProperty, @IoIgnore, @IoCreator, @IoValue, @IoFormat, @IoNaming, and more) — with Jackson annotation compatibility at zero compile-time cost
  • Spring Boot starter — expanded YAML configuration for WriteOptions and ReadOptions without writing Java code
  • TOON format enhancements — tabular POJO format, configurable delimiters, cycle support with $id/$ref, and full type metadata emission
  • Significant performance optimizations across parser, writer, resolver, and injector hot paths

Features

  • Spring Boot starter — expanded YAML configuration properties. All commonly used WriteOptions/ReadOptions settings now configurable via application.yml. New write properties: force-map-output-as-two-arrays, write-enum-as-json-object, cycle-support, json5, date-format, indentation-size, show-root-type-info, meta-prefix, toon-delimiter. New read properties: use-unsafe, floating-point, integer-type.
  • AnnotationResolver — 25 annotations in com.cedarsoftware.io.annotation for full declarative serialization control: @IoProperty, @IoIgnore, @IoIgnoreProperties, @IoAlias, @IoPropertyOrder, @IoInclude, @IoCreator, @IoValue, @IoNaming, @IoIncludeProperties, @IoIgnoreType, @IoTypeInfo, @IoDeserialize, @IoClassFactory, @IoGetter, @IoSetter, @IoNonReferenceable, @IoNotCustomReader, @IoNotCustomWritten, @IoCustomWriter, @IoCustomReader, @IoTypeName, @IoAnySetter, @IoAnyGetter, @IoFormat.
  • Jackson annotation compatibility — json-io reflectively honors Jackson annotations when the Jackson JAR is on the classpath with zero compile-time dependency. json-io annotations take priority.
  • ToonWriter — tabular format for POJO collections/arrays (compact CSV-style [N]{field1,field2,...}: row1 row2 ...).
  • ToonWriter — configurable delimiters (comma, tab, pipe) encoded in count bracket for auto-detection on read.
  • ToonWriter — TOON type metadata emission (@type/@t/$type/$t) when type output is enabled.
  • ToonWriter — defaults TOON metadata keys to $ variants ($id/$ref/$items/$keys) for JSON5-friendly output.
  • ToonWriter — uses WriteFieldPlan/Accessor abstraction, giving TOON automatic support for all write-side annotations.

Improvements

  • @type elimination — now considers @IoDeserialize(as=X) and @IoTypeInfo(X) annotations, producing smaller JSON without sacrificing round-trip fidelity.
  • AnnotationResolver — uses ClassUtilities.forName() for proper classloader resolution in OSGi/JPMS environments.

Performance

  • Accessor.retrieve() — sticky fallback flags for lambda/VarHandle/MethodHandle paths; failed paths bypassed on subsequent calls.
  • Injector — numeric kind and primitive-wrapper lookups now use ClassValueMap O(1) dispatch.
  • Injector.inject() — assignability-based pre-conversion reduces exception-driven control flow.
  • JsonIo — thread-local buffer recycling in String-based JSON paths removes repeated stream/buffer construction.
  • JsonObject.appendFieldForParser() — parser-only fast path avoids indexOf duplicate-key search.
  • JsonParser — read numeric pipeline optimized with direct Double.parseDouble() fast path for DOUBLE mode and primitive-array direct assignment.
  • JsonParser — ASCII-only lowercase conversion, lookup-table hex parsing, bounded string dedupe caching, simplified strict-mode handling.
  • JsonWriter — string escaping with precomputed control escape strings; unified smart-quote decision logic.
  • JsonWriter — class-cached custom-writer gate checks via ClassValueMap.
  • JsonWritercycleSupport(false) bypasses objsReferenced/@id lookup across all write hot paths.
  • JsonWriter.writeMapBody() — hoisted invariants reduce per-entry branch checks.
  • Resolver — target-kind based scalar coercion with precomputed kinds in array/field hot loops and direct no-allocation primitive array writes.
  • ReadOptionsBuilder / WriteOptionsBuilder — cached injector/write-field planning reduces repeated reflection/generic analysis.

Bug Fixes

  • JsonWriter.write() — always clears objVisited/objsReferenced in finally block, preventing state leakage.
  • JsonWriter.traceReferences() — fixed off-by-one in object-limit enforcement.
  • JsonWriter / ToonWritercycleSupport(false) throws JsonIoException with remediation hint; cycleSupport(true) retains normal id/ref handling.
  • ObjectResolver — map generic typing preserves both key and value generic types during traversal.
  • ObjectResolver.processJsonObjectElement() — preserves explicit element @type metadata in arrays for polymorphic deserialization.
  • ObjectResolver — generic inference now runs incrementally instead of deep markUntypedObjects() pre-pass.
  • ObjectResolver.assignField() — applies @IoDeserialize/@IoTypeInfo overrides for TOON list-style arrays/maps.
  • Resolver.wrapException() — preserves causal chain with JsonIoException(message, cause).
  • Resolver.toJava() — supports TOON key/value entry-list conversion for concrete Map subclasses.
  • ToonWriter — applies @IoProperty rename and @IoPropertyOrder reordering.
  • ToonWriter — indents nested referenced-map id metadata correctly.
  • ToonReader — recognizes all TOON metadata key variants for full id/ref identity round-trip.

Install

Maven

<dependency>
  <groupId>com.cedarsoftware</groupId>
  <artifactId>json-io</artifactId>
  <version>4.96.0</version>
</dependency>

Gradle

implementation 'com.cedarsoftware:json-io:4.96.0'