Skip to content

Commit

Permalink
Add missing commonMain folder to fuel-kotlinx-serialization project (#…
Browse files Browse the repository at this point in the history
…914)

* Oops, how i forget to check this. :(

* Update ResponseExtensions.kt

* Update ResponseExtensions.kt

* Update ResponseExtensions.kt
  • Loading branch information
iNoles authored Jun 6, 2024
1 parent 11d7e96 commit ca65c9c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
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 {
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

0 comments on commit ca65c9c

Please sign in to comment.