Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 124 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,32 @@ references.
directly in the schema, alongside numbers, strings, lists, maps, arrays,
enums, structs, and unions. Define schemas once, then generate native domain
objects for each language without forcing wrapper types into user code.
- **Row-Format Random Access**: Read fields, arrays, and nested values without
rebuilding full objects, with zero-copy access and partial reads.
- **Optimized Implementations**: Java JIT serializers and generated/static serializers
in other language implementations keep hot paths fast and payloads compact.
- **Language And Platform Support**: Java, Python, C++, Go, Rust,
JavaScript/TypeScript, C#, Swift, Dart, Scala, and Kotlin, including GraalVM
native image, Android, Dart VM/Flutter/web, and Node.js/browser JavaScript.

For same-language workloads, Fory provides native serialization modes that
support broader language-specific object models:

- **Java Native Serialization**: A high-performance replacement for JDK
serialization, Hessian, Kryo, and FST in Java-only systems. It supports JDK
custom serialization semantics.
- **Python Native Serialization**: A faster and more compact replacement for
`pickle` and `cloudpickle` in Python-only systems. It supports classes,
modules, functions, and custom object state, with fine-grained
deserialization controls through `DeserializationPolicy`.

Fory also provides specialized formats for other data-processing requirements:

- **Row Format**: Read fields, arrays, and nested values without rebuilding
complete objects, with zero-copy access and partial reads.
- **Fory JSON**: A Java JSON serialization framework built for maximum
throughput through runtime-generated codecs and optimized readers and
writers. Supports Java 8 and later on standard JDKs, GraalVM native images,
and Android, including Java 17 records.

## Performance

Benchmarks show Fory delivering higher throughput and smaller serialized
Expand Down Expand Up @@ -292,13 +310,14 @@ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md).
Snapshots for Java, Scala, and Kotlin are available from
`https://repository.apache.org/snapshots/` with the matching `-SNAPSHOT` version.

## Choose Serialization Mode
## Choose a Serialization Format

| Mode | Use it when | Start here |
| ----------- | ------------------------------------------------------------- | -------------------------------------------------------- |
| Xlang mode | Data crosses language boundaries | [Cross-language guide](docs/guide/xlang) |
| Native mode | Producer and consumer are in the same language | Language guide |
| Row format | You need random field access or analytics-style partial reads | [Row format spec](docs/specification/row_format_spec.md) |
| Format | Use it when | Start here |
| ------------- | ------------------------------------------------------------- | -------------------------------------------------------- |
| Xlang binary | Data crosses language boundaries | [Cross-language guide](docs/guide/xlang) |
| Native binary | Producer and consumer are in the same language | Language guide |
| Row format | You need random field access or analytics-style partial reads | [Row format spec](docs/specification/row_format_spec.md) |
| Fory JSON | Java applications need high-performance standard JSON | [Fory JSON guide](docs/guide/java/json-support.md) |

For Java, Scala, Kotlin, Python, C++, Go, and Rust, use native mode for
same-language traffic. It avoids xlang's cross-language type mapping and
Expand Down Expand Up @@ -680,11 +699,25 @@ val fory = ForyKotlin.builder()

## Schema IDL

Fory IDL is Fory's schema language for shared data models. It supports
references, nullable fields, lists, maps, arrays, enums, messages, and unions,
and generates native data structures for Java, Python, C++, Go, Rust,
JavaScript/TypeScript, C#, Swift, Dart, Scala, and Kotlin. Use it when multiple
languages need one shared contract.
Fory IDL is Fory's schema-first path for shared data models. Use it when
multiple languages need one explicit contract, stable field identities, and
generated native domain objects instead of manually coordinating equivalent
types in every implementation.

The schema supports primitive values, nullable fields, lists, maps, dense
arrays, enums, messages, unions, imports, and first-class shared or circular
references. The compiler generates idiomatic models and Fory integration for
Java, Python, C++, Go, Rust, JavaScript/TypeScript, C#, Swift, Dart, Scala, and
Kotlin. It can also generate Fory-backed gRPC service companions for supported
languages.

Install the compiler from PyPI:

```bash
pip install fory-compiler
```

Define the shared model in `tree.fdl`:

```protobuf
package tree;
Expand All @@ -698,7 +731,18 @@ message TreeNode {
}
```

See the [Fory IDL and compiler guide](https://fory.apache.org/docs/compiler).
Generate native models for the languages used by your application:

```bash
foryc tree.fdl --lang java,python,rust --output ./generated
```

Generated types use each language's normal classes, structs, dataclasses,
annotations, macros, or registration helpers, so application code works with
native domain objects while all peers share the same Fory schema. See the
[Fory IDL and compiler guide](https://fory.apache.org/docs/compiler) for the
complete type system, language-specific output options, schema evolution, and
gRPC generation.

## Row Format

Expand Down Expand Up @@ -761,6 +805,72 @@ deserialization, see the
[Python row-format guide](docs/guide/python/row-format.md), and the
[row-format specification](docs/specification/row_format_spec.md).

## Fory JSON

Fory JSON is a thread-safe JSON serialization framework for Java, extensively
optimized for maximum performance across JSON encoding, decoding, and Java
object mapping. It supports Java 8 and later on standard JDKs, GraalVM native
images, and Android, with Java records supported on Java 17 and later.

Add Fory JSON to your project:

**Maven**

```xml
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-json</artifactId>
<version>1.4.0</version>
</dependency>
```

**Gradle**

```gradle
implementation "org.apache.fory:fory-json:1.4.0"
```

Keep all Fory modules in the same application on the same version.

**Quick Start**

Build one `ForyJson` instance and reuse it across threads:

```java
import org.apache.fory.json.ForyJson;

public final class JsonExample {
private static final ForyJson JSON = ForyJson.builder().build();

public static final class User {
public long id;
public String name;

public User() {}

public User(long id, String name) {
this.id = id;
this.name = name;
}
}

public static void main(String[] args) {
User input = new User(7, "Alice");

String text = JSON.toJson(input);
User fromText = JSON.fromJson(text, User.class);

byte[] bytes = JSON.toJsonBytes(input);
User fromBytes = JSON.fromJson(bytes, User.class);

System.out.println(fromText.name + " / " + fromBytes.name);
}
}
```

See the [Fory JSON guide](docs/guide/java/json-support.md) for installation,
configuration, supported types, custom codecs, and platform-specific setup.

## Documentation

**User Guides**
Expand Down
Loading
Loading