Skip to content

Commit f102e60

Browse files
committed
Merge remote-tracking branch 'origin/master' into dev
2 parents aed6cef + 66f3238 commit f102e60

File tree

8 files changed

+27
-21
lines changed

8 files changed

+27
-21
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ repositories {
148148
}
149149

150150
dependencies {
151-
implementation(kotlin("stdlib", KotlinCompilerVersion.VERSION)) // or "stdlib-jdk8"
152151
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0")
153152
}
154153
```
@@ -162,7 +161,6 @@ repositories {
162161
}
163162
164163
dependencies {
165-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // or "kotlin-stdlib-jdk8"
166164
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0"
167165
}
168166
```

docs/json.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ Project(name=kotlinx.serialization, language=Kotlin)
198198

199199
### Encoding defaults
200200

201-
Default values of properties don't have to be encoded, because they will be reconstructed during encoding anyway.
202-
It can be configured by the [encodeDefaults][JsonBuilder.encodeDefaults] property.
203-
This is especially useful for nullable properties with null defaults to avoid writing the corresponding
204-
null values.
201+
Default values of properties are not encoded by default, because they will be reconstructed during decoding anyway.
202+
See [Defaults are not encoded](basic-serialization.md#defaults-are-not-encoded) section for details with example.
203+
This is especially useful for nullable properties with null defaults and avoids writing the corresponding null values.
204+
The default behavior can be changed by the [encodeDefaults][JsonBuilder.encodeDefaults] property.
205205

206206
```kotlin
207-
val format = Json { encodeDefaults = false }
207+
val format = Json { encodeDefaults = true }
208208

209209
@Serializable
210210
class Project(
@@ -221,10 +221,10 @@ fun main() {
221221

222222
> You can get the full code [here](../guide/example/example-json-05.kt).
223223
224-
Produces the following output which has only the `name` property:
224+
It produces the following output which encodes the values of all the properties:
225225

226226
```text
227-
{"name":"kotlinx.serialization"}
227+
{"name":"kotlinx.serialization","language":"Kotlin","website":null}
228228
```
229229

230230
<!--- TEST -->
@@ -372,7 +372,7 @@ A [JsonElement] class has three direct subtypes, closely following JSON grammar.
372372
* [JsonObject] represents a JSON `{...}` object. It is a Kotlin [Map] from `String` key to `JsonElement` value.
373373

374374
The `JsonElement` class has `jsonXxx` extensions that cast it to its corresponding subtypes
375-
([jsonPrimitive], [jsonArray], [jsonObject]). The `JsonPrimitive` class, in turn,
375+
([jsonPrimitive][_jsonPrimitive], [jsonArray][_jsonArray], [jsonObject][_jsonObject]). The `JsonPrimitive` class, in turn,
376376
has convenient converters to Kotlin primitive types ([int], [intOrNull], [long], [longOrNull], etc)
377377
that allow fluent code to work with JSON for which you know the structure of.
378378

@@ -916,9 +916,9 @@ The next chapter covers [Alternative and custom formats (experimental)](formats.
916916
[JsonPrimitive()]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-primitive.html
917917
[JsonArray]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-array/index.html
918918
[JsonObject]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-object/index.html
919-
[jsonPrimitive]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-element/index.html#kotlinx.serialization.json%2F%2FjsonPrimitive%2Fkotlinx.serialization.json.JsonElement%23%2FPointingToDeclaration%2F
920-
[jsonArray]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-element/index.html#kotlinx.serialization.json%2F%2FjsonArray%2Fkotlinx.serialization.json.JsonElement%23%2FPointingToDeclaration%2F
921-
[jsonObject]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-element/index.html#kotlinx.serialization.json%2F%2FjsonObject%2Fkotlinx.serialization.json.JsonElement%23%2FPointingToDeclaration%2F
919+
[_jsonPrimitive]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-element/index.html#kotlinx.serialization.json%2F%2FjsonPrimitive%2Fkotlinx.serialization.json.JsonElement%23%2FPointingToDeclaration%2F
920+
[_jsonArray]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-element/index.html#kotlinx.serialization.json%2F%2FjsonArray%2Fkotlinx.serialization.json.JsonElement%23%2FPointingToDeclaration%2F
921+
[_jsonObject]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-element/index.html#kotlinx.serialization.json%2F%2FjsonObject%2Fkotlinx.serialization.json.JsonElement%23%2FPointingToDeclaration%2F
922922
[int]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-primitive/index.html#kotlinx.serialization.json%2F%2Fint%2Fkotlinx.serialization.json.JsonPrimitive%23%2FPointingToDeclaration%2F
923923
[intOrNull]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-primitive/index.html#kotlinx.serialization.json%2F%2FintOrNull%2Fkotlinx.serialization.json.JsonPrimitive%23%2FPointingToDeclaration%2F
924924
[long]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json-primitive/index.html#kotlinx.serialization.json%2F%2Flong%2Fkotlinx.serialization.json.JsonPrimitive%23%2FPointingToDeclaration%2F

docs/polymorphism.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ must be explicitly registered at runtime.
274274
Let us start with the code from the [Designing serializable hierarchy](#designing-serializable-hierarchy) section.
275275
To make it work with serialization without making it `sealed`, we have to define a [SerializersModule] using the
276276
[SerializersModule {}][SerializersModule()] builder function. In the module the base class is specified
277-
in the [polymorphic] builder and each subclass is registered with the [subclass] function. Now,
277+
in the [polymorphic][_polymorphic] builder and each subclass is registered with the [subclass] function. Now,
278278
a custom JSON configuration can be instantiated with this module and used for serialization.
279279

280280
> Details on custom JSON configurations can be found in
@@ -875,7 +875,7 @@ The next chapter covers [JSON features](json.md).
875875
<!--- INDEX kotlinx-serialization-core/kotlinx.serialization.modules -->
876876
[SerializersModule]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/-serializers-module/index.html
877877
[SerializersModule()]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/-serializers-module.html
878-
[polymorphic]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/polymorphic.html
878+
[_polymorphic]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/polymorphic.html
879879
[subclass]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/subclass.html
880880
[plus]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/plus.html
881881
[SerializersModuleBuilder.include]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/-serializers-module-builder/include.html

docs/serializers.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ class ProgrammingLanguage(
879879
To provide a context, we define a [SerializersModule] instance that describes which serializers shall be used
880880
at run-time to serialize which contextually-serializable classes. This is done using the
881881
[SerializersModule {}][SerializersModule()] builder function, which provides [SerializersModuleBuilder] DSL to
882-
register serializers. In the below example we use [contextual] function with the serializer. The corresponding
882+
register serializers. In the below example we use [contextual][_contextual] function with the serializer. The corresponding
883883
class this serializer is defined for is fetched automatically via the `reified` type parameter.
884884
885885
```kotlin
@@ -1005,7 +1005,6 @@ The next chapter covers [Polymorphism](polymorphism.md).
10051005
[Serializable]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/-serializable/index.html
10061006
[KSerializer]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/-k-serializer/index.html
10071007
[KSerializer.descriptor]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/-k-serializer/index.html#kotlinx.serialization%2FKSerializer%2Fdescriptor%2F%23%2FPointingToDeclaration%2F
1008-
[kotlinx.serialization.serializer]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/../../../kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/index.html#kotlinx.serialization%2F%2Fserializer%2F%23%2FPointingToDeclaration%2F
10091008
[SerializationStrategy.serialize]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/-serialization-strategy/serialize.html
10101009
[SerializationStrategy]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/-serialization-strategy/index.html
10111010
[DeserializationStrategy.deserialize]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization/-deserialization-strategy/deserialize.html
@@ -1047,7 +1046,7 @@ The next chapter covers [Polymorphism](polymorphism.md).
10471046
[SerializersModule]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/-serializers-module/index.html
10481047
[SerializersModule()]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/-serializers-module.html
10491048
[SerializersModuleBuilder]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/-serializers-module-builder/index.html
1050-
[contextual]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/contextual.html
1049+
[_contextual]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx-serialization-core/kotlinx.serialization.modules/contextual.html
10511050
<!--- MODULE /kotlinx-serialization-json -->
10521051
<!--- INDEX kotlinx-serialization-json/kotlinx.serialization.json -->
10531052
[Json]: https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx-serialization-json/kotlinx.serialization.json/-json/index.html

formats/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ not be available in other formats such as JSON.
7777

7878
Allows serialization and deserialization of objects to and from [YAML](http://yaml.org).
7979

80+
### YAML (Multiplatform)
81+
82+
* GitHub repo: [him188/yamlkt](https://github.com/him188/yamlkt)
83+
* Artifact ID: `net.mamoe.yamlkt:yamlkt`
84+
* Platform: all supported platforms
85+
86+
Allows serialization and deserialization of objects to and from [YAML](http://yaml.org).
87+
Basic serial operations have been implemented, but some features such as compound keys and polymorphism are still work in progress.
88+
8089
### CBOR
8190

8291
* GitHub repo: [L-Briand/obor](https://github.com/L-Briand/obor)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jackson_version=2.10.0.pr1
1616
dokka_version=1.4.20-multimodule-dev-7
1717
native.deploy=
1818
validator_version=0.2.3
19-
knit_version=0.2.1
19+
knit_version=0.2.2
2020
coroutines_version=1.3.9
2121

2222
kotlin.mpp.enableGranularSourceSetsMetadata=true

guide/example/example-json-05.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package example.exampleJson05
44
import kotlinx.serialization.*
55
import kotlinx.serialization.json.*
66

7-
val format = Json { encodeDefaults = false }
7+
val format = Json { encodeDefaults = true }
88

99
@Serializable
1010
class Project(

guide/test/JsonTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class JsonTest {
3939
@Test
4040
fun testExampleJson05() {
4141
captureOutput("ExampleJson05") { example.exampleJson05.main() }.verifyOutputLines(
42-
"{\"name\":\"kotlinx.serialization\"}"
42+
"{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\",\"website\":null}"
4343
)
4444
}
4545

0 commit comments

Comments
 (0)