Skip to content

Fix codegen for sparse collection JSON serialization#3757

Open
kai-ion wants to merge 2 commits intomainfrom
nullObj
Open

Fix codegen for sparse collection JSON serialization#3757
kai-ion wants to merge 2 commits intomainfrom
nullObj

Conversation

@kai-ion
Copy link
Contributor

@kai-ion kai-ion commented Mar 23, 2026

Issue #, if available:

Description of changes:
The Velocity template for serializing sparse (nullable) list and map
elements had two issues:

  1. Called AsNull() on JsonValue array elements, but AsNull() only exists on the CRT's JsonObject, not on the SDK's JsonValue wrapper.

  2. Used *optional.Method() to access the inner value of Optional-wrapped elements. Due to C++ operator precedence, .Method() binds to the Optional rather than the dereferenced value. This is harmless for simple types (strings, ints) where computeJsonizeString returns empty, but breaks for structures (.Jsonize()), timestamps (.SecondsWithMSPrecision()), and documents (.View()). Fixed by using optional->Method() via computeJsonizeString(shape, true) for types that require a method call.

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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.

1 participant