Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmedmourad0/bundlizer
Android Bundle format support for Kotlinx Serialization.
https://github.com/ahmedmourad0/bundlizer
android android-library bundle kotlinx kotlinx-serialization marshalling
Last synced: 2 months ago
JSON representation
Android Bundle format support for Kotlinx Serialization.
- Host: GitHub
- URL: https://github.com/ahmedmourad0/bundlizer
- Owner: AhmedMourad0
- License: apache-2.0
- Created: 2020-04-03T12:25:34.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-15T15:06:13.000Z (12 months ago)
- Last Synced: 2024-06-19T09:41:32.856Z (8 months ago)
- Topics: android, android-library, bundle, kotlinx, kotlinx-serialization, marshalling
- Language: Kotlin
- Size: 116 KB
- Stars: 77
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
Bundlizer ![CI](https://github.com/AhmedMourad0/bundlizer/workflows/CI/badge.svg) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.ahmedmourad.bundlizer/bundlizer-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.ahmedmourad.bundlizer/bundlizer-core)
===================================================================================Android Bundle format support for Kotlinx Serialization.
## Usage
Annotate your data models with `@Serializable`:
```kotlin
import kotlinx.serialization.Serializableenum class Type {
HUMAN, MONKEY
}@Serializable
data class Email(val value: String)@Serializable
data class User(
val id: Int,
val name: String,
val email: Email,
val friends: List?,
val something: Map,
val type: Type
)
```### To Bundle
Use `Bundlizer.bundle` or `bundle` extension function:
```kotlin
import dev.ahmedmourad.bundlizer.Bundlizer
import dev.ahmedmourad.bundlizer.bundle
import android.os.Bundleval user: User = ...
val bundle: Bundle = Bundlizer.bundle(User.serializer(), user)
// or
val bundle: Bundle = user.bundle(User.serializer())
```### From Bundle
Use `Bundlizer.unbundle` or `unbundle` extension function:```kotlin
import dev.ahmedmourad.bundlizer.Bundlizer
import dev.ahmedmourad.bundlizer.unbundle
import android.os.Bundleval bundle: Bundle = ...
val user: User = Bundlizer.unbundle(User.serializer(), bundle)
// or
val user: User = bundle.unbundle(User.serializer())
```## Installation
- Add [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) to your project.
- In your module-level `build.gradle`:
```gradle
repositories {
mavenCentral()
}dependencies {
implementation "dev.ahmedmourad.bundlizer:bundlizer-core:0.8.0"
}
```License
-------Copyright (C) 2020 Ahmed Mourad
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.[snapshots]: https://oss.sonatype.org/content/repositories/snapshots/