How kptfh/json-reactive works
Project type and purpose
• Project type: A multi-module Java library providing reactive JSON binding on top of Jackson’s non-blocking parser.
• Purpose: Offer core non-blocking JSON parsing plus two reactive adapters (Reactor and RxJava2) so consumers can stream POJOs reactively.
File structure
Top-level modules (in pom.xml):
– json-nonblocking
– json-reactor
– json-rx2
Each module is a standard Maven sub-project, containing source under src/main/java and tests under src/test/java.
– json-nonblocking implements core asynchronous parsing (classes under com.fasterxml.jackson.core.async_ and reactivejson packages).
– json-reactor wraps the core parser into Project Reactor’s Flux<T>.
– json-rx2 wraps the core parser into RxJava2’s Flowable<T>.
Shared dependencies: Jackson Core (JsonFactory, NonBlockingJsonParser), plus Reactor or RxJava2.
README for additional insights
• Modules description confirms the structure.
• Usage snippets show how users instantiate ReactorObjectReader or Rx2ObjectReader with JsonFactory and an ObjectReader<T> to produce a reactive stream of POJOs.
a. Core Non-Blocking Parser Module (json-nonblocking):
– Jackson’s JsonFactory → NonBlockingJsonParser
– Tokenizer and NonBlockingObjectReader that feed raw tokens into POJO binding
b. Reactive Adapters:
– Reactor Adapter (json-reactor): ReactorObjectReader → produces Flux<T>
– Rx2 Adapter (json-rx2): Rx2ObjectReader → produces Flowable<T>
c. External Libraries:
– Jackson Core (for JsonFactory, low-level parser)
– Project Reactor (for Flux)
– RxJava2 (for Flowable)
d. Consumer Layer: Your application code or any downstream service subscribing to the reactive streams.
Relationships and data flow
– Input: ByteBuffer stream of JSON data
– Core module parses bytes asynchronously → emits JSON tokens
– Tokenizer/NonBlockingObjectReader converts tokens to Java objects via Jackson’s ObjectReader<T>
– Reactive adapter wraps the reader output into a Flux<T> or Flowable<T>
– Consumer subscribes, processes or persists POJOs
Architectural patterns and design principles
– Modular layering: Core parsing is decoupled from reactive frameworks
– Adapter pattern: Reactor and Rx2 modules adapt the same core API to different reactive types
– Dependency inversion: Core defines abstractions (NonBlockingObjectReader), adapters depend on those, not vice versa
– Separation of concerns: Parsing, tokenization, binding, and streaming are distinct layers