Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
iNoles committed Jun 16, 2024
2 parents a3cc1b7 + e047276 commit 052672d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 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, body.string())
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, response?.json().toString())
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ artifactUrl=https://github.com/kittinunf/fuel
artifactScm=git@github.com:kittinunf/fuel.git
artifactLicenseName=MIT License
artifactLicenseUrl=http://www.opensource.org/licenses/mit-license.php
artifactPublishVersion=3.0.0-alpha02
artifactPublishVersion=3.0.0-alpha03
artifactGroupId=com.github.kittinunf.fuel

0 comments on commit 052672d

Please sign in to comment.