Skip to content

Commit

Permalink
JsonObject was removed from GBJson
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan-Kim committed Dec 27, 2024
1 parent 407cf68 commit 27fbdc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class GrowthBookSDK() : FeaturesFlowDelegate {
is GBBoolean -> gbFeatureResult.value.value as? V
is GBString -> gbFeatureResult.value.value as? V
is GBNumber -> gbFeatureResult.value.value as? V
is GBJson -> gbFeatureResult.value.value as? V
is GBJson -> gbFeatureResult.value as? V
is GBValue.Unknown -> null
null -> null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import kotlinx.serialization.json.longOrNull
data class GBBoolean(val value: Boolean): GBValue()
data class GBString(val value: String): GBValue()
data class GBNumber(val value: Number): GBValue()
data class GBJson(val value: JsonObject): GBValue()
data class GBJson(
private val value: Map<String, GBValue>,
): GBValue(), Map<String, GBValue> by value

sealed class GBValue {
data object Unknown: GBValue()
Expand All @@ -40,7 +42,9 @@ sealed class GBValue {
is GBBoolean -> JsonPrimitive(this.value)
is GBString -> JsonPrimitive(this.value)
is GBNumber -> JsonPrimitive(this.value)
is GBJson -> this.value
is GBJson -> JsonObject(
this.mapValues { it.value.gbSerialize() }
)
is Unknown -> JsonNull
}

Expand All @@ -66,7 +70,9 @@ sealed class GBValue {
else -> Unknown
}
}
is JsonObject -> GBJson(jsonElement)
is JsonObject -> GBJson(
jsonElement.mapValues { from(it.value) }
)
else -> Unknown
}
}
Expand Down

0 comments on commit 27fbdc8

Please sign in to comment.