Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lisonge/kotlin-json5
kotlin multiplatform json5 for kotlinx.serialization
https://github.com/lisonge/kotlin-json5
json5 kotlin kotlin-multiplatform kotlin-serialization
Last synced: 4 months ago
JSON representation
kotlin multiplatform json5 for kotlinx.serialization
- Host: GitHub
- URL: https://github.com/lisonge/kotlin-json5
- Owner: lisonge
- License: apache-2.0
- Created: 2024-08-14T03:59:33.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T06:04:40.000Z (6 months ago)
- Last Synced: 2024-10-04T21:56:10.775Z (4 months ago)
- Topics: json5, kotlin, kotlin-multiplatform, kotlin-serialization
- Language: Kotlin
- Homepage:
- Size: 74.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kotlin-json5
kotlin multiplatform json5 for [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization)
## usage
```kotlin
implementation("li.songe:json5:0.0.1")
```Json5String -> JsonElement
```kotlin
val element = Json5.parseToJson5Element("{a:1}")
```JsonElement -> Json5String
```kotlin
val formatted: String = Json5.encodeToString(element, 2)
```interop with `kotlinx.serialization`
```kotlin
val json = Json {
// add your json config
ignoreUnknownKeys = true
}
data class A(val id:Int)// Json5String -> T
val a = json.decodeFromJson5String("{id:0, b:''}")// T -> Json5String
val formatted: String = json.encodeToJson5String(a)
```