Skip to content

Commit

Permalink
Oops, how i forget to check this. :(
Browse files Browse the repository at this point in the history
  • Loading branch information
iNoles committed May 28, 2024
1 parent 11d7e96 commit d092569
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 { allowStructuredMapKeys = true },
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 d092569

Please sign in to comment.