This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory-site.git
The following commit(s) were added to refs/heads/main by this push:
new 5a6f3605bb 🔄 synced local 'docs/compiler/' with remote 'docs/compiler/'
5a6f3605bb is described below
commit 5a6f3605bba3d89ab1ecbfb6d1b1f843291e5cda
Author: chaokunyang <[email protected]>
AuthorDate: Tue Apr 14 03:59:24 2026 +0000
🔄 synced local 'docs/compiler/' with remote 'docs/compiler/'
---
docs/compiler/compiler-guide.md | 38 ++++--
docs/compiler/generated-code.md | 82 +++++++++---
docs/compiler/index.md | 15 +--
docs/compiler/schema-idl.md | 267 +++++++++++++++++++++-------------------
4 files changed, 240 insertions(+), 162 deletions(-)
diff --git a/docs/compiler/compiler-guide.md b/docs/compiler/compiler-guide.md
index 78d62ed59e..dc6585ea4c 100644
--- a/docs/compiler/compiler-guide.md
+++ b/docs/compiler/compiler-guide.md
@@ -64,6 +64,7 @@ Compile options:
| `--go_out=DST_DIR` | Generate Go code in DST_DIR
| (none) |
| `--rust_out=DST_DIR` | Generate Rust code in DST_DIR
| (none) |
| `--csharp_out=DST_DIR` | Generate C# code in DST_DIR
| (none) |
+| `--javascript_out=DST_DIR` | Generate JavaScript code in DST_DIR
| (none) |
| `--swift_out=DST_DIR` | Generate Swift code in DST_DIR
| (none) |
| `--go_nested_type_style` | Go nested type naming: `camelcase`
or `underscore` | `underscore` |
| `--swift_namespace_style` | Swift namespace style: `enum` or
`flatten` | `enum` |
@@ -115,7 +116,7 @@ foryc schema.fdl
**Compile for specific languages:**
```bash
-foryc schema.fdl --lang java,python,csharp,swift
+foryc schema.fdl --lang java,python,csharp,javascript,swift
```
**Specify output directory:**
@@ -168,7 +169,7 @@ foryc src/main.fdl -I libs/common,libs/types --proto_path
third_party/
foryc schema.fdl --java_out=./src/main/java
# Generate multiple languages to different directories
-foryc schema.fdl --java_out=./java/gen --python_out=./python/src
--go_out=./go/gen --csharp_out=./csharp/gen --swift_out=./swift/gen
+foryc schema.fdl --java_out=./java/gen --python_out=./python/src
--go_out=./go/gen --csharp_out=./csharp/gen --javascript_out=./javascript/src
--swift_out=./swift/gen
# Combine with import paths
foryc schema.fdl --java_out=./gen/java -I proto/ -I common/
@@ -237,15 +238,16 @@ Compiling src/main.fdl...
## Supported Languages
-| Language | Flag | Output Extension | Description |
-| -------- | -------- | ---------------- | ---------------------------- |
-| Java | `java` | `.java` | POJOs with Fory annotations |
-| Python | `python` | `.py` | Dataclasses with type hints |
-| Go | `go` | `.go` | Structs with struct tags |
-| Rust | `rust` | `.rs` | Structs with derive macros |
-| C++ | `cpp` | `.h` | Structs with FORY macros |
-| C# | `csharp` | `.cs` | Classes with Fory attributes |
-| Swift | `swift` | `.swift` | `@ForyObject` Swift models |
+| Language | Flag | Output Extension | Description
|
+| ---------- | ------------ | ---------------- |
------------------------------------- |
+| Java | `java` | `.java` | POJOs with Fory annotations
|
+| Python | `python` | `.py` | Dataclasses with type hints
|
+| Go | `go` | `.go` | Structs with struct tags
|
+| Rust | `rust` | `.rs` | Structs with derive macros
|
+| C++ | `cpp` | `.h` | Structs with FORY macros
|
+| C# | `csharp` | `.cs` | Classes with Fory attributes
|
+| JavaScript | `javascript` | `.ts` | Interfaces with registration
function |
+| Swift | `swift` | `.swift` | `@ForyObject` Swift models
|
## Output Structure
@@ -315,6 +317,20 @@ generated/
- Namespace matches package (dots to `::`)
- Header guards and forward declarations
+### JavaScript
+
+```
+generated/
+└── javascript/
+ └── example.ts
+```
+
+- Single `.ts` file per schema
+- `export interface` declarations for messages
+- `export enum` declarations for enums
+- Discriminated unions with case enums
+- Registration helper function included
+
### C\#
```
diff --git a/docs/compiler/generated-code.md b/docs/compiler/generated-code.md
index dcf9bce3b1..d6835b6439 100644
--- a/docs/compiler/generated-code.md
+++ b/docs/compiler/generated-code.md
@@ -744,6 +744,50 @@ public static class AddressbookForyRegistration
When explicit type IDs are not provided, generated registration uses computed
numeric IDs (same behavior as other targets).
+## JavaScript
+
+### Output Layout
+
+JavaScript output is one `.ts` file per schema, for example:
+
+- `<javascript_out>/addressbook.ts`
+
+### Type Generation
+
+Messages generate `export interface` declarations with camelCase field names:
+
+```typescript
+export interface Person {
+ name: string;
+ id: number;
+ phones: PhoneNumber[];
+ pet?: Animal | null;
+}
+```
+
+Enums generate `export enum` declarations:
+
+```typescript
+export enum PhoneType {
+ MOBILE = 0,
+ HOME = 1,
+ WORK = 2,
+}
+```
+
+Unions generate a discriminated union with a case enum:
+
+```typescript
+export enum AnimalCase {
+ DOG = 1,
+ CAT = 2,
+}
+
+export type Animal =
+ | { case: AnimalCase.DOG; value: Dog }
+ | { case: AnimalCase.CAT; value: Cat };
+```
+
## Swift
### Output Layout
@@ -826,24 +870,26 @@ If `option enable_auto_type_id = false;` is set,
generated code uses name-based
### Nested Type Shape
-| Language | Nested type form |
-| -------- | ------------------------------ |
-| Java | `Person.PhoneNumber` |
-| Python | `Person.PhoneNumber` |
-| Rust | `person::PhoneNumber` |
-| C++ | `Person::PhoneNumber` |
-| Go | `Person_PhoneNumber` (default) |
-| C# | `Person.PhoneNumber` |
-| Swift | `Person.PhoneNumber` |
+| Language | Nested type form |
+| ---------- | ------------------------------ |
+| Java | `Person.PhoneNumber` |
+| Python | `Person.PhoneNumber` |
+| Rust | `person::PhoneNumber` |
+| C++ | `Person::PhoneNumber` |
+| Go | `Person_PhoneNumber` (default) |
+| C# | `Person.PhoneNumber` |
+| JavaScript | `Person.PhoneNumber` |
+| Swift | `Person.PhoneNumber` |
### Byte Helper Naming
-| Language | Helpers |
-| -------- | ------------------------- |
-| Java | `toBytes` / `fromBytes` |
-| Python | `to_bytes` / `from_bytes` |
-| Rust | `to_bytes` / `from_bytes` |
-| C++ | `to_bytes` / `from_bytes` |
-| Go | `ToBytes` / `FromBytes` |
-| C# | `ToBytes` / `FromBytes` |
-| Swift | `toBytes` / `fromBytes` |
+| Language | Helpers |
+| ---------- | ------------------------- |
+| Java | `toBytes` / `fromBytes` |
+| Python | `to_bytes` / `from_bytes` |
+| Rust | `to_bytes` / `from_bytes` |
+| C++ | `to_bytes` / `from_bytes` |
+| Go | `ToBytes` / `FromBytes` |
+| C# | `ToBytes` / `FromBytes` |
+| JavaScript | (via `fory.serialize()`) |
+| Swift | `toBytes` / `fromBytes` |
diff --git a/docs/compiler/index.md b/docs/compiler/index.md
index 63c0a0659d..52408c7ffe 100644
--- a/docs/compiler/index.md
+++ b/docs/compiler/index.md
@@ -21,7 +21,7 @@ license: |
Fory IDL is a schema definition language for Apache Fory that enables type-safe
cross-language serialization. Define your data structures once and generate
-native data structure code for Java, Python, Go, Rust, C++, C#, and Swift.
+native data structure code for Java, Python, Go, Rust, C++, C#, Swift, and
JavaScript.
## Example Schema
@@ -101,6 +101,7 @@ Generated code uses native language constructs:
- Rust: Structs with `#[derive(ForyObject)]`
- C++: Structs with `FORY_STRUCT` macros
- C#: Classes with `[ForyObject]` and registration helpers
+- JavaScript: Interfaces with registration function
- Swift: `@ForyObject` models with `@ForyField` metadata and registration
helpers
## Quick Start
@@ -139,7 +140,7 @@ message Person {
foryc example.fdl --output ./generated
# Generate for specific languages
-foryc example.fdl --lang java,python,csharp,swift --output ./generated
+foryc example.fdl --lang java,python,csharp,javascript,swift --output
./generated
```
### 4. Use Generated Code
@@ -194,11 +195,11 @@ message Example {
Fory IDL types map to native types in each language:
-| Fory IDL Type | Java | Python | Go | Rust | C++
| C# | Swift |
-| ------------- | --------- | -------------- | -------- | -------- |
------------- | -------- | -------- |
-| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t`
| `int` | `Int32` |
-| `string` | `String` | `str` | `string` | `String` |
`std::string` | `string` | `String` |
-| `bool` | `boolean` | `bool` | `bool` | `bool` | `bool`
| `bool` | `Bool` |
+| Fory IDL Type | Java | Python | Go | Rust | C++
| C# | JavaScript | Swift |
+| ------------- | --------- | -------------- | -------- | -------- |
------------- | -------- | ---------- | -------- |
+| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t`
| `int` | `number` | `Int32` |
+| `string` | `String` | `str` | `string` | `String` |
`std::string` | `string` | `string` | `String` |
+| `bool` | `boolean` | `bool` | `bool` | `bool` | `bool`
| `bool` | `boolean` | `Bool` |
See [Type System](schema-idl.md#type-system) for complete mappings.
diff --git a/docs/compiler/schema-idl.md b/docs/compiler/schema-idl.md
index c66803be6b..d94d6e536f 100644
--- a/docs/compiler/schema-idl.md
+++ b/docs/compiler/schema-idl.md
@@ -93,14 +93,15 @@ package com.example.models alias models_v1;
**Language Mapping:**
-| Language | Package Usage |
-| -------- | --------------------------------- |
-| Java | Java package |
-| Python | Module name (dots to underscores) |
-| Go | Package name (last component) |
-| Rust | Module name (dots to underscores) |
-| C++ | Namespace (dots to `::`) |
-| C# | Namespace |
+| Language | Package Usage |
+| ---------- | --------------------------------- |
+| Java | Java package |
+| Python | Module name (dots to underscores) |
+| Go | Package name (last component) |
+| Rust | Module name (dots to underscores) |
+| C++ | Namespace (dots to `::`) |
+| C# | Namespace |
+| JavaScript | Module name (last segment) |
## File-Level Options
@@ -542,13 +543,14 @@ FDL does not support `option ...;` statements inside enum
bodies.
### Language Mapping
-| Language | Implementation |
-| -------- | -------------------------------------- |
-| Java | `enum Status { UNKNOWN, ACTIVE, ... }` |
-| Python | `class Status(IntEnum): UNKNOWN = 0` |
-| Go | `type Status int32` with constants |
-| Rust | `#[repr(i32)] enum Status { Unknown }` |
-| C++ | `enum class Status : int32_t { ... }` |
+| Language | Implementation |
+| ---------- | -------------------------------------- |
+| Java | `enum Status { UNKNOWN, ACTIVE, ... }` |
+| Python | `class Status(IntEnum): UNKNOWN = 0` |
+| Go | `type Status int32` with constants |
+| Rust | `#[repr(i32)] enum Status { Unknown }` |
+| C++ | `enum class Status : int32_t { ... }` |
+| JavaScript | `export enum Status { UNKNOWN, ... }` |
### Enum Prefix Stripping
@@ -565,13 +567,14 @@ enum DeviceTier {
**Generated code:**
-| Language | Output | Style |
-| -------- | ----------------------------------------- | -------------- |
-| Java | `UNKNOWN, TIER1, TIER2` | Scoped enum |
-| Rust | `Unknown, Tier1, Tier2` | Scoped enum |
-| C++ | `UNKNOWN, TIER1, TIER2` | Scoped enum |
-| Python | `UNKNOWN, TIER1, TIER2` | Scoped IntEnum |
-| Go | `DeviceTierUnknown, DeviceTierTier1, ...` | Unscoped const |
+| Language | Output | Style |
+| ---------- | ----------------------------------------- | -------------- |
+| Java | `UNKNOWN, TIER1, TIER2` | Scoped enum |
+| Rust | `Unknown, Tier1, Tier2` | Scoped enum |
+| C++ | `UNKNOWN, TIER1, TIER2` | Scoped enum |
+| Python | `UNKNOWN, TIER1, TIER2` | Scoped IntEnum |
+| Go | `DeviceTierUnknown, DeviceTierTier1, ...` | Unscoped const |
+| JavaScript | `UNKNOWN, TIER1, TIER2` | Scoped enum |
**Note:** The prefix is only stripped if the remainder is a valid identifier.
For example, `DEVICE_TIER_1` is kept unchanged because `1` is not a valid
identifier name.
@@ -641,13 +644,14 @@ message Person { // Auto-generated when
enable_auto_type_id = true
### Language Mapping
-| Language | Implementation |
-| -------- | ----------------------------------- |
-| Java | POJO class with getters/setters |
-| Python | `@dataclass` class |
-| Go | Struct with exported fields |
-| Rust | Struct with `#[derive(ForyObject)]` |
-| C++ | Struct with `FORY_STRUCT` macro |
+| Language | Implementation |
+| ---------- | ----------------------------------- |
+| Java | POJO class with getters/setters |
+| Python | `@dataclass` class |
+| Go | Struct with exported fields |
+| Rust | Struct with `#[derive(ForyObject)]` |
+| C++ | Struct with `FORY_STRUCT` macro |
+| JavaScript | `export interface` declaration |
Type IDs control cross-language registration for messages, unions, and enums.
See
[Type IDs](#type-ids) for auto-generation, aliases, and collision handling.
@@ -764,13 +768,14 @@ message OtherMessage {
### Language-Specific Generation
-| Language | Nested Type Generation
|
-| -------- |
---------------------------------------------------------------------------------
|
-| Java | Static inner classes (`SearchResponse.Result`)
|
-| Python | Nested classes within dataclass
|
-| Go | Flat structs with underscore (`SearchResponse_Result`,
configurable to camelcase) |
-| Rust | Nested modules (`search_response::Result`)
|
-| C++ | Nested classes (`SearchResponse::Result`)
|
+| Language | Nested Type Generation
|
+| ---------- |
---------------------------------------------------------------------------------
|
+| Java | Static inner classes (`SearchResponse.Result`)
|
+| Python | Nested classes within dataclass
|
+| Go | Flat structs with underscore (`SearchResponse_Result`,
configurable to camelcase) |
+| Rust | Nested modules (`search_response::Result`)
|
+| C++ | Nested classes (`SearchResponse::Result`)
|
+| JavaScript | Flat names (`Result`)
|
**Note:** Go defaults to underscore-separated nested names; set `option
go_nested_type_style = "camelcase";` to use concatenated names. Rust emits
nested modules for nested types.
@@ -866,13 +871,14 @@ message User {
**Generated Code:**
-| Language | Non-optional | Optional
|
-| -------- | ------------------ |
----------------------------------------------- |
-| Java | `String name` | `String email` with
`@ForyField(nullable=true)` |
-| Python | `name: str` | `name: Optional[str]`
|
-| Go | `Name string` | `Name *string`
|
-| Rust | `name: String` | `name: Option<String>`
|
-| C++ | `std::string name` | `std::optional<std::string> name`
|
+| Language | Non-optional | Optional
|
+| ---------- | ------------------ |
----------------------------------------------- |
+| Java | `String name` | `String email` with
`@ForyField(nullable=true)` |
+| Python | `name: str` | `name: Optional[str]`
|
+| Go | `Name string` | `Name *string`
|
+| Rust | `name: String` | `name: Option<String>`
|
+| C++ | `std::string name` | `std::optional<std::string> name`
|
+| JavaScript | `name: string` | `name?: string \| null`
|
**Default Values:**
@@ -901,13 +907,14 @@ message Node {
**Generated Code:**
-| Language | Without `ref` | With `ref` |
-| -------- | -------------- | ----------------------------------------- |
-| Java | `Node parent` | `Node parent` with `@ForyField(ref=true)` |
-| Python | `parent: Node` | `parent: Node = pyfory.field(ref=True)` |
-| Go | `Parent Node` | `Parent *Node` with `fory:"ref"` |
-| Rust | `parent: Node` | `parent: Arc<Node>` |
-| C++ | `Node parent` | `std::shared_ptr<Node> parent` |
+| Language | Without `ref` | With `ref` |
+| ---------- | -------------- | ----------------------------------------- |
+| Java | `Node parent` | `Node parent` with `@ForyField(ref=true)` |
+| Python | `parent: Node` | `parent: Node = pyfory.field(ref=True)` |
+| Go | `Parent Node` | `Parent *Node` with `fory:"ref"` |
+| Rust | `parent: Node` | `parent: Arc<Node>` |
+| C++ | `Node parent` | `std::shared_ptr<Node> parent` |
+| JavaScript | `parent: Node` | `parent: Node` (no ref distinction) |
Rust uses `Arc` by default; use `ref(thread_safe=false)` or `ref(weak=true)`
to customize pointer types. For protobuf option syntax, see
@@ -926,13 +933,14 @@ message Document {
**Generated Code:**
-| Language | Type |
-| -------- | -------------------------- |
-| Java | `List<String>` |
-| Python | `List[str]` |
-| Go | `[]string` |
-| Rust | `Vec<String>` |
-| C++ | `std::vector<std::string>` |
+| Language | Type |
+| ---------- | -------------------------- |
+| Java | `List<String>` |
+| Python | `List[str]` |
+| Go | `[]string` |
+| Rust | `Vec<String>` |
+| C++ | `std::vector<std::string>` |
+| JavaScript | `string[]` |
### Combining Modifiers
@@ -1021,13 +1029,14 @@ collection behavior, and reference tracking (see
#### Boolean
-| Language | Type | Notes |
-| -------- | --------------------- | ------------------ |
-| Java | `boolean` / `Boolean` | Primitive or boxed |
-| Python | `bool` | |
-| Go | `bool` | |
-| Rust | `bool` | |
-| C++ | `bool` | |
+| Language | Type | Notes |
+| ---------- | --------------------- | ------------------ |
+| Java | `boolean` / `Boolean` | Primitive or boxed |
+| Python | `bool` | |
+| Go | `bool` | |
+| Rust | `bool` | |
+| C++ | `bool` | |
+| JavaScript | `boolean` | |
#### Integer Types
@@ -1042,12 +1051,12 @@ Fory IDL provides fixed-width signed integers (varint
encoding for 32/64-bit by
**Language Mapping (Signed):**
-| Fory IDL | Java | Python | Go | Rust | C++ |
-| -------- | ------- | -------------- | ------- | ----- | --------- |
-| `int8` | `byte` | `pyfory.int8` | `int8` | `i8` | `int8_t` |
-| `int16` | `short` | `pyfory.int16` | `int16` | `i16` | `int16_t` |
-| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t` |
-| `int64` | `long` | `pyfory.int64` | `int64` | `i64` | `int64_t` |
+| Fory IDL | Java | Python | Go | Rust | C++ |
JavaScript |
+| -------- | ------- | -------------- | ------- | ----- | --------- |
------------------ |
+| `int8` | `byte` | `pyfory.int8` | `int8` | `i8` | `int8_t` | `number`
|
+| `int16` | `short` | `pyfory.int16` | `int16` | `i16` | `int16_t` | `number`
|
+| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t` | `number`
|
+| `int64` | `long` | `pyfory.int64` | `int64` | `i64` | `int64_t` | `bigint
\| number` |
Fory IDL provides fixed-width unsigned integers (varint encoding for 32/64-bit
by default):
@@ -1060,12 +1069,12 @@ Fory IDL provides fixed-width unsigned integers (varint
encoding for 32/64-bit b
**Language Mapping (Unsigned):**
-| Fory IDL | Java | Python | Go | Rust | C++ |
-| -------- | ------- | --------------- | -------- | ----- | ---------- |
-| `uint8` | `short` | `pyfory.uint8` | `uint8` | `u8` | `uint8_t` |
-| `uint16` | `int` | `pyfory.uint16` | `uint16` | `u16` | `uint16_t` |
-| `uint32` | `long` | `pyfory.uint32` | `uint32` | `u32` | `uint32_t` |
-| `uint64` | `long` | `pyfory.uint64` | `uint64` | `u64` | `uint64_t` |
+| Fory IDL | Java | Python | Go | Rust | C++ |
JavaScript |
+| -------- | ------- | --------------- | -------- | ----- | ---------- |
------------------ |
+| `uint8` | `short` | `pyfory.uint8` | `uint8` | `u8` | `uint8_t` |
`number` |
+| `uint16` | `int` | `pyfory.uint16` | `uint16` | `u16` | `uint16_t` |
`number` |
+| `uint32` | `long` | `pyfory.uint32` | `uint32` | `u32` | `uint32_t` |
`number` |
+| `uint64` | `long` | `pyfory.uint64` | `uint64` | `u64` | `uint64_t` |
`bigint \| number` |
#### Integer Encoding Variants
@@ -1090,62 +1099,67 @@ you need fixed-width or tagged encoding:
**Language Mapping:**
-| Fory IDL | Java | Python | Go | Rust | C++ |
-| --------- | -------- | ---------------- | --------- | ----- | -------- |
-| `float32` | `float` | `pyfory.float32` | `float32` | `f32` | `float` |
-| `float64` | `double` | `pyfory.float64` | `float64` | `f64` | `double` |
+| Fory IDL | Java | Python | Go | Rust | C++ |
JavaScript |
+| --------- | -------- | ---------------- | --------- | ----- | -------- |
---------- |
+| `float32` | `float` | `pyfory.float32` | `float32` | `f32` | `float` |
`number` |
+| `float64` | `double` | `pyfory.float64` | `float64` | `f64` | `double` |
`number` |
#### String Type
-| Language | Type | Notes |
-| -------- | ------------- | --------------------- |
-| Java | `String` | Immutable |
-| Python | `str` | |
-| Go | `string` | Immutable |
-| Rust | `String` | Owned, heap-allocated |
-| C++ | `std::string` | |
+| Language | Type | Notes |
+| ---------- | ------------- | --------------------- |
+| Java | `String` | Immutable |
+| Python | `str` | |
+| Go | `string` | Immutable |
+| Rust | `String` | Owned, heap-allocated |
+| C++ | `std::string` | |
+| JavaScript | `string` | |
#### Bytes Type
-| Language | Type | Notes |
-| -------- | ---------------------- | --------- |
-| Java | `byte[]` | |
-| Python | `bytes` | Immutable |
-| Go | `[]byte` | |
-| Rust | `Vec<u8>` | |
-| C++ | `std::vector<uint8_t>` | |
+| Language | Type | Notes |
+| ---------- | ---------------------- | --------- |
+| Java | `byte[]` | |
+| Python | `bytes` | Immutable |
+| Go | `[]byte` | |
+| Rust | `Vec<u8>` | |
+| C++ | `std::vector<uint8_t>` | |
+| JavaScript | `Uint8Array` | |
#### Temporal Types
##### Date
-| Language | Type | Notes |
-| -------- | --------------------------- | ----------------------- |
-| Java | `java.time.LocalDate` | |
-| Python | `datetime.date` | |
-| Go | `time.Time` | Time portion ignored |
-| Rust | `chrono::NaiveDate` | Requires `chrono` crate |
-| C++ | `fory::serialization::Date` | |
+| Language | Type | Notes |
+| ---------- | --------------------------- | ----------------------- |
+| Java | `java.time.LocalDate` | |
+| Python | `datetime.date` | |
+| Go | `time.Time` | Time portion ignored |
+| Rust | `chrono::NaiveDate` | Requires `chrono` crate |
+| C++ | `fory::serialization::Date` | |
+| JavaScript | `Date` | |
##### Timestamp
-| Language | Type | Notes |
-| -------- | -------------------------------- | ----------------------- |
-| Java | `java.time.Instant` | UTC-based |
-| Python | `datetime.datetime` | |
-| Go | `time.Time` | |
-| Rust | `chrono::NaiveDateTime` | Requires `chrono` crate |
-| C++ | `fory::serialization::Timestamp` | |
+| Language | Type | Notes |
+| ---------- | -------------------------------- | ----------------------- |
+| Java | `java.time.Instant` | UTC-based |
+| Python | `datetime.datetime` | |
+| Go | `time.Time` | |
+| Rust | `chrono::NaiveDateTime` | Requires `chrono` crate |
+| C++ | `fory::serialization::Timestamp` | |
+| JavaScript | `Date` | |
#### Any
-| Language | Type | Notes |
-| -------- | -------------- | -------------------- |
-| Java | `Object` | Runtime type written |
-| Python | `Any` | Runtime type written |
-| Go | `any` | Runtime type written |
-| Rust | `Box<dyn Any>` | Runtime type written |
-| C++ | `std::any` | Runtime type written |
+| Language | Type | Notes |
+| ---------- | -------------- | -------------------- |
+| Java | `Object` | Runtime type written |
+| Python | `Any` | Runtime type written |
+| Go | `any` | Runtime type written |
+| Rust | `Box<dyn Any>` | Runtime type written |
+| C++ | `std::any` | Runtime type written |
+| JavaScript | `any` | Runtime type written |
**Example:**
@@ -1167,13 +1181,14 @@ message Envelope [id=122] {
**Generated Code (`Envelope.payload`):**
-| Language | Generated Field Type |
-| -------- | ----------------------- |
-| Java | `Object payload` |
-| Python | `payload: Any` |
-| Go | `Payload any` |
-| Rust | `payload: Box<dyn Any>` |
-| C++ | `std::any payload` |
+| Language | Generated Field Type |
+| ---------- | ----------------------- |
+| Java | `Object payload` |
+| Python | `payload: Any` |
+| Go | `Payload any` |
+| Rust | `payload: Box<dyn Any>` |
+| C++ | `std::any payload` |
+| JavaScript | `payload: any` |
**Notes:**
@@ -1224,10 +1239,10 @@ message Config {
**Language Mapping:**
-| Fory IDL | Java | Python | Go
| Rust | C++ |
-| -------------------- | ---------------------- | ----------------- |
------------------ | ----------------------- | --------------------------------
|
-| `map<string, int32>` | `Map<String, Integer>` | `Dict[str, int]` |
`map[string]int32` | `HashMap<String, i32>` | `std::map<std::string, int32_t>`
|
-| `map<string, User>` | `Map<String, User>` | `Dict[str, User]` |
`map[string]User` | `HashMap<String, User>` | `std::map<std::string, User>`
|
+| Fory IDL | Java | Python | Go
| Rust | C++ |
JavaScript |
+| -------------------- | ---------------------- | ----------------- |
------------------ | ----------------------- | --------------------------------
| --------------------- |
+| `map<string, int32>` | `Map<String, Integer>` | `Dict[str, int]` |
`map[string]int32` | `HashMap<String, i32>` | `std::map<std::string, int32_t>`
| `Map<string, number>` |
+| `map<string, User>` | `Map<String, User>` | `Dict[str, User]` |
`map[string]User` | `HashMap<String, User>` | `std::map<std::string, User>`
| `Map<string, User>` |
**Key Type Restrictions:**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]