Skip to content

[FSSDK-12617] Deserialize integers as longs when using Gson#624

Open
FarhanAnjum-opti wants to merge 5 commits intomasterfrom
jamiesanson/FSSDK-12617-gson-deserialize-integers-as-longs
Open

[FSSDK-12617] Deserialize integers as longs when using Gson#624
FarhanAnjum-opti wants to merge 5 commits intomasterfrom
jamiesanson/FSSDK-12617-gson-deserialize-integers-as-longs

Conversation

@FarhanAnjum-opti
Copy link
Copy Markdown
Contributor

@FarhanAnjum-opti FarhanAnjum-opti commented May 7, 2026

Summary

Deserialize integers as longs instead of doubles when using Gson. This allows users to use the resultant Map in downstream serializers (e.g. kotlinx.serialization) more easily.

Changes

  • Added ToNumberPolicy.LONG_OR_DOUBLE to GsonConfigParser so integers deserialize as Long instead of Double
  • Updated GsonConfigParserTest to verify integer parsing and fix assertion argument order
  • Updated OptimizelyJSONWithGsonParserTest to reflect Long expected values

Testing

  • Updated existing tests to validate new behavior
  • Added integer-specific test case in testFromJson

Related

Copy link
Copy Markdown
Contributor

@muzahidul-opti muzahidul-opti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of suggestions by AI

  • Consider adding a test case for nested integer values in GsonConfigParserTest.testFromJson — the OptimizelyJSONWithGsonParserTest covers nested objects, but the parser-level test only covers flat values.
  • Update the comment in OptimizelyJSON.getValueInternal from Integer, Double to Long, Double (or just Number) since the behavior has changed. (Not in scope of this PR, just noting.)

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

Successfully merging this pull request may close these issues.

3 participants