Skip to content

Commit

Permalink
1.4.1
Browse files Browse the repository at this point in the history
add gson customization
  • Loading branch information
A.Badakhshan committed Feb 27, 2023
1 parent 64cbb65 commit 4bfeb26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ayannetworking/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.4.0"
versionName "1.4.1"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class AyanApi(
val request =
AyanRequest(
finalIdentity, if (stringParameters) {
EscapedParameters(Gson().toJson(input), endPoint)
EscapedParameters((gson ?: Gson()).toJson(input), endPoint)
} else {
input
}
Expand All @@ -189,9 +189,9 @@ class AyanApi(
try {
if (logLevel == LogLevel.LOG_ALL) {
try {
Log.d("AyanReq", endPoint + ":\n" + Gson().toJson(request).toPrettyFormat())
Log.d("AyanReq", endPoint + ":\n" + (gson ?: Gson()).toJson(request).toPrettyFormat())
} catch (e: Exception) {
Log.d("AyanReq", endPoint + ":\n" + Gson().toJson(request))
Log.d("AyanReq", endPoint + ":\n" + (gson ?: Gson()).toJson(request))
}
}
} catch (e: Exception) {
Expand Down Expand Up @@ -250,21 +250,21 @@ class AyanApi(
parameters = when (jsonObject.get("Parameters")) {
is JsonObject -> {
if (stringParameters)
Gson().fromJson(
(gson ?: Gson()).fromJson(
(jsonObject.get("Parameters") as JsonObject).get(
"Params"
).asString,
typeToken.type
)
else {
Gson().fromJson(
(gson ?: Gson()).fromJson(
jsonObject.getAsJsonObject("Parameters"),
typeToken.type
)
}
}
is JsonArray -> {
Gson().fromJson(
(gson ?: Gson()).fromJson(
jsonObject.getAsJsonArray("Parameters"),
typeToken.type
)
Expand All @@ -279,7 +279,7 @@ class AyanApi(
Log.e("Attention", e.message ?: "")
}
val status =
Gson().fromJson(
(gson ?: Gson()).fromJson(
jsonObject.getAsJsonObject("Status"),
Status::class.java
)
Expand Down

0 comments on commit 4bfeb26

Please sign in to comment.