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 c04c4252761 docs: use User in release blog Kotlin examples (#498)
c04c4252761 is described below
commit c04c4252761494c1ec95a5a68084dd733e7cf264
Author: Shawn Yang <[email protected]>
AuthorDate: Mon Aug 31 11:52:08 2026 +0800
docs: use User in release blog Kotlin examples (#498)
---
blog/2026-08-28-fory_1_7_0_released.md | 8 ++++----
.../2026-08-28-fory_1_7_0_released.md | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/blog/2026-08-28-fory_1_7_0_released.md
b/blog/2026-08-28-fory_1_7_0_released.md
index 5c8a52ae459..72db8079f90 100644
--- a/blog/2026-08-28-fory_1_7_0_released.md
+++ b/blog/2026-08-28-fory_1_7_0_released.md
@@ -62,17 +62,17 @@ Use `jsonTypeRef<T>()` to retain Kotlin type information at
the root and in nest
import org.apache.fory.json.kotlin.ForyJsonKotlin
import org.apache.fory.json.kotlin.jsonTypeRef
-data class Account(
+data class User(
val id: ULong,
val name: String,
val nickname: String? = null,
)
val json = ForyJsonKotlin.builder().build()
-val accountType = jsonTypeRef<Account>()
+val userType = jsonTypeRef<User>()
-val account = json.fromJson("""{"id":7,"name":"Alice"}""", accountType)
-val text = json.toJson(account, accountType)
+val user = json.fromJson("""{"id":7,"name":"Alice"}""", userType)
+val text = json.toJson(user, userType)
```
A missing member invokes its constructor default when one exists. An explicit
JSON `null` is checked against the Kotlin declaration and never requests a
default. Fory calls the model's constructor, so initialization and validation
still run. Sealed classes and interfaces can use `JsonSubTypes` to declare a
closed set of logical subtype names.
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-blog/2026-08-28-fory_1_7_0_released.md
b/i18n/zh-CN/docusaurus-plugin-content-blog/2026-08-28-fory_1_7_0_released.md
index 14298cda50d..26cb958f914 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-blog/2026-08-28-fory_1_7_0_released.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-blog/2026-08-28-fory_1_7_0_released.md
@@ -62,17 +62,17 @@ dependencies {
import org.apache.fory.json.kotlin.ForyJsonKotlin
import org.apache.fory.json.kotlin.jsonTypeRef
-data class Account(
+data class User(
val id: ULong,
val name: String,
val nickname: String? = null,
)
val json = ForyJsonKotlin.builder().build()
-val accountType = jsonTypeRef<Account>()
+val userType = jsonTypeRef<User>()
-val account = json.fromJson("""{"id":7,"name":"Alice"}""", accountType)
-val text = json.toJson(account, accountType)
+val user = json.fromJson("""{"id":7,"name":"Alice"}""", userType)
+val text = json.toJson(user, userType)
```
成员缺失时,如果构造函数提供默认值,就调用该默认值。显式 JSON `null` 按 Kotlin 声明进行检查,不会请求使用默认值。Fory
会调用模型构造函数,因此初始化和验证逻辑仍会执行。sealed 类和接口可通过 `JsonSubTypes` 声明一组封闭的逻辑子类型名。
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]