-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alejo
committed
Jun 20, 2023
1 parent
db3112a
commit a4e1737
Showing
4 changed files
with
27 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/utils/JsonStringUtils.kt
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/utils/JsonUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.wordpress.android.fluxc.utils | ||
|
||
import com.google.gson.JsonElement | ||
|
||
const val EMPTY_JSON_ARRAY = "[]" | ||
|
||
fun JsonElement?.isElementNullOrEmpty(): Boolean { | ||
return this?.let { | ||
if (it.isJsonNull) return@let true | ||
when{ | ||
this.isJsonObject -> this.asJsonObject.size() == 0 | ||
this.isJsonArray -> this.asJsonArray.size()== 0 | ||
this.isJsonPrimitive && this.asJsonPrimitive.isString -> this.asString.isEmpty() | ||
this.isJsonNull -> true | ||
else -> false | ||
} | ||
} ?: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters