Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Var<string> does not work unless string is quoted so its valid json #101

Open
cmcpasserby opened this issue Nov 29, 2024 · 0 comments
Open

Comments

@cmcpasserby
Copy link

Anytime .Value is read from on a Var<string>, the string is treated as if its json when it is not, and the Value getter on AndroidVar and IOSVar ends up just returning defaultValue instead of the modified string from the dashboard.

The cause of this is from

public override T Value {
get {
string jsonRepresentation = CleverTapAndroidJNI.CleverTapJNIInstance.Call<string>("getVariableValue", name);
if (jsonRepresentation == Json.Serialize(value)) {
return value;
}
object newValue = Json.Deserialize(jsonRepresentation);
if (newValue is IDictionary) {
Util.FillInValues(newValue, value);
} else if (newValue == null) {
value = defaultValue;
} else {
value = (T)Convert.ChangeType(newValue, typeof(T));
}
return value;
}
}

and
public override T Value {
get {
string jsonRepresentation = IOSDllImport.CleverTap_getVariableValue(name, kind);
if (jsonRepresentation == null) {
return defaultValue;
}
if (jsonRepresentation == Json.Serialize(value)) {
return value;
}
object newValue = Json.Deserialize(jsonRepresentation);
if (newValue is IDictionary) {
Util.FillInValues(newValue, value);
} else {
value = (T)Convert.ChangeType(newValue, typeof(T));
}
return value;
}

Because the string is always treated as json, even know getVariableValue will return exactly the string provided on the dashboard and not a json object containing a string. Thus the object newValue = Json.Deserialize(jsonRepresentation); line always returns null causing things to always get into the branch that returns default value.

I suspect this was caused by the fix in https://github.com/CleverTap/clevertap-unity-sdk/pull/61/files where all strings used to return quoted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant