Skip to content

Installation ​

SJF4J supports Java 8+. Individual backend libraries may require a newer Java version.

Replace every {version} with the current Maven Central version.

The guides may cover changes ahead of a published release. The latest Javadoc describes the latest published API; for exact signatures, consult the Javadoc matching your dependency version.

Quick Setup ​

Install sjf4j-core and add only the modules you need. These examples use Jackson 2.x as the JSON backend.

kotlin
dependencies {
    implementation("org.sjf4j:sjf4j-core:{version}")

    // Optional: Jackson 2.x backend and its library
    implementation("org.sjf4j:sjf4j-backend-jackson2:{version}")
    implementation("com.fasterxml.jackson.core:jackson-databind:2.22.3")

    // Optional: JSON Schema validation
    implementation("org.sjf4j:sjf4j-schema:{version}")

    // Optional: Compiled APIs
    annotationProcessor("org.sjf4j:sjf4j-processor:{version}")
}
xml
<dependencies>
    <dependency>
        <groupId>org.sjf4j</groupId>
        <artifactId>sjf4j-core</artifactId>
        <version>{version}</version>
    </dependency>

    <!-- Optional: Jackson 2.x backend and its library -->
    <dependency>
        <groupId>org.sjf4j</groupId>
        <artifactId>sjf4j-backend-jackson2</artifactId>
        <version>{version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.22.3</version>
    </dependency>

    <!-- Optional: JSON Schema validation -->
    <dependency>
        <groupId>org.sjf4j</groupId>
        <artifactId>sjf4j-schema</artifactId>
        <version>{version}</version>
    </dependency>
</dependencies>

sjf4j-core includes Simple JSON and Java Properties support, so no external backend is required for those formats. For compiled APIs with Maven, configure the annotation processor separately.

Modules ​

SJF4J module dependencies

ModulePurposeDepends on
sjf4j-coreStructural APIs, binding, navigation, mapping and patching—
sjf4j-schemaJSON Schema validationCore
sjf4j-processorCompile-time code generationCore, Schema
sjf4j-springRegister compiled interfaces as Spring Beans (Java 17+)Core, Spring Framework
sjf4j-spring-boot-starterSpring Boot auto-configuration for compiled APIs (Java 17+)Spring, Spring Boot
sjf4j-backend-*JSON/YAML backend adaptersCore
sjf4jAll-in-one: Core, Schema and six adaptersAll above except Processor

Prefer modular dependencies to keep the classpath small. Alternatively, install the aggregate artifact:

kotlin
implementation("org.sjf4j:sjf4j:{version}")
xml
<dependency>
    <groupId>org.sjf4j</groupId>
    <artifactId>sjf4j</artifactId>
    <version>{version}</version>
</dependency>

The aggregate includes all six SJF4J adapters, but not their third-party libraries or the annotation processor.

Backends ​

The complete set of built-in and optional backends:

FormatBackendSJF4J moduleRequired third-party library
JSONJackson 3.xsjf4j-backend-jackson3tools.jackson.core:jackson-databind:3.2.3
JSONJackson 2.xsjf4j-backend-jackson2com.fasterxml.jackson.core:jackson-databind:2.22.3
JSONGsonsjf4j-backend-gsoncom.google.code.gson:gson:2.13.1
JSONFastjson2sjf4j-backend-fastjson2com.alibaba.fastjson2:fastjson2:2.0.66
JSONJSON-Psjf4j-backend-jsonpjakarta.json:jakarta.json-api:2.1.3 and provider org.eclipse.parsson:parsson:1.1.7
JSONSimplesjf4j-coreNone
YAMLSnakeYAMLsjf4j-backend-snakeorg.yaml:snakeyaml:2.5
PropertiesBuilt-insjf4j-coreNone

The versions shown are those used by the SJF4J project; compatible library versions may also work. For each external backend, add both its SJF4J module and third-party library. The libraries are not transitively included.

Automatic JSON selection (highest priority first):

Jackson 3 → Jackson 2 → Gson → Fastjson2 → JSON-P → Simple

SJF4J chooses the first available built-in backend in this order. Runtime binding discovers providers through ServiceLoader; @CompiledBinder(backend = Backend.AUTO) selects a backend at compile time. Both require the corresponding adapter and native library (JSON-P also requires an implementation). Simple is the built-in fallback.

YAML uses SnakeYAML when available; Java Properties support is built in. See Backends & Formats for selection rules and explicit overrides.

Compiled APIs ​

Add sjf4j-processor to the annotation processor path (not as a normal runtime dependency).

Gradle: use the annotationProcessor(...) declaration shown in Quick Setup.

Maven: configure the compiler plugin:

xml
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.sjf4j</groupId>
                        <artifactId>sjf4j-processor</artifactId>
                        <version>{version}</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>

@CompiledValidator also requires sjf4j-schema at runtime. Other compiled APIs do not need the schema module unless they use JSON Schema functionality.

Learn more: Compiled APIs · Binding · Validating

Spring Integration ​

Both options require Java 17+ and annotation processing.

Spring Framework ​

For plain Spring Framework 6.2+, enable compiled interface registration with @EnableSjf4j.

kotlin
implementation("org.sjf4j:sjf4j-spring:{version}")
annotationProcessor("org.sjf4j:sjf4j-processor:{version}")
xml
<dependency>
    <groupId>org.sjf4j</groupId>
    <artifactId>sjf4j-spring</artifactId>
    <version>{version}</version>
</dependency>
java
@Configuration
@EnableSjf4j
public class AppConfig {
}

Spring Boot ​

For Spring Boot 3.x, use the Starter. It enables the same integration automatically; no @EnableSjf4j annotation is required.

kotlin
implementation("org.sjf4j:sjf4j-spring-boot-starter:{version}")
annotationProcessor("org.sjf4j:sjf4j-processor:{version}")
xml
<dependency>
    <groupId>org.sjf4j</groupId>
    <artifactId>sjf4j-spring-boot-starter</artifactId>
    <version>{version}</version>
</dependency>

Both options bring in sjf4j-core transitively. For Maven, configure the annotation processor separately. Other optional SJF4J modules are added as needed.

See Spring Integration for dependency injection, Spring Converter, and JdbcTemplate examples.

Released under the MIT License.