Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing commonMain folder to fuel-kotlinx-serialization project #914

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import fuel.HttpResponse
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.json.Json

public fun <T : Any> HttpResponse.toJson(
json: Json = Json { allowStructuredMapKeys = true },
public actual fun <T : Any> HttpResponse.toJson(
json: Json,
kittinunf marked this conversation as resolved.
Show resolved Hide resolved
deserializationStrategy: DeserializationStrategy<T>
): Result<T?, Throwable> = runCatching {
body?.let { json.decodeFromString(deserializationStrategy, it) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package fuel.serialization

import com.github.kittinunf.result.Result
import fuel.HttpResponse
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.json.Json

public expect fun <T : Any> HttpResponse.toJson(
json: Json = Json,
deserializationStrategy: DeserializationStrategy<T>
): Result<T?, Throwable>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import fuel.HttpResponse
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.json.Json

public fun <T : Any> HttpResponse.toJson(
json: Json = Json { allowStructuredMapKeys = true },
public actual fun <T : Any> HttpResponse.toJson(
json: Json,
deserializationStrategy: DeserializationStrategy<T>
): Result<T?, Throwable> = runCatching {
json.decodeFromString(deserializationStrategy, response?.json().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import fuel.HttpResponse
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.json.Json

public fun <T : Any> HttpResponse.toJson(
json: Json = Json { allowStructuredMapKeys = true },
public actual fun <T : Any> HttpResponse.toJson(
json: Json,
deserializationStrategy: DeserializationStrategy<T>
): Result<T?, Throwable> = runCatching {
json.decodeFromString(deserializationStrategy, body.string())
Expand Down
Loading