diff options
author | Leonid Startsev <sandwwraith@gmail.com> | 2021-04-08 19:17:00 +0300 |
---|---|---|
committer | Leonid Startsev <sandwwraith@users.noreply.github.com> | 2021-04-14 13:59:19 +0300 |
commit | 436cf833b523c85bfc28d66b4e0cccc11396d238 (patch) | |
tree | e8dd0df42a840efaee6f1eaa75f3ead585be2227 /docs | |
parent | f7b7f193eed5ac41f54806175fffb9aa9b47b231 (diff) | |
download | kotlinx.serialization-436cf833b523c85bfc28d66b4e0cccc11396d238.tar.gz |
Replace Array<String> in JsonNames with vararg
Migrate to 1.5.0-M2 to do so (because vararg in serialinfo requires IR)
Diffstat (limited to 'docs')
-rw-r--r-- | docs/json.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/json.md b/docs/json.md index e37e6c23..db1a63cf 100644 --- a/docs/json.md +++ b/docs/json.md @@ -154,14 +154,14 @@ Project(name=kotlinx.serialization) ### Alternative Json names -It's not a rare case when JSON fields got renamed due to a schema version change or something else. +It's not a rare case when JSON fields got renamed due to a schema version change. Renaming JSON fields is available with [`@SerialName` annotation](basic-serialization.md#serial-field-names), but -such a renaming blocks ability to decode data with old name. +such a renaming blocks ability to decode data with an old name. For the case when we want to support multiple JSON names for the one Kotlin property, there is a [JsonNames] annotation: ```kotlin @Serializable -data class Project(@JsonNames(["title"]) val name: String) +data class Project(@JsonNames("title") val name: String) fun main() { val project = Json.decodeFromString<Project>("""{"name":"kotlinx.serialization"}""") |