Skip to content

fix(serialization-json): serialize nested arrays recursively - #730

Merged
Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
rksharma-owg:codex/serialize-nested-json-arrays
Sep 11, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
microsoft:mainfrom
rksharma-owg:codex/serialize-nested-json-arrays

Conversation

@rksharma-owg

@rksharma-owg RKS (rksharma-owg) commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

write_any_value("matrix", [[1, 2, 3]]) raises TypeError because the list dispatcher has no branch for nested lists.

Add an explicit all(isinstance(x, list) for x in value) branch, consistent with the neighboring dictionary check, and delegate to the existing recursive element writer. Keep the existing unknown-collection exception and specialized collection paths. This supports nested lists without accepting previously unsupported mixtures of lists and scalar/model/dictionary values at the same level.

Validation (Python 3.12):

  • Regression coverage includes root/property values, additional data, empty arrays, dictionaries, model objects, and dates within nested lists.
  • Three rejection cases failed before the review update and pass after it, confirming mixed collections retain the existing TypeError.
  • JSON package: pytest -q — 120 passed.
  • YAPF, isort, mypy, and git diff --check passed.
  • Pylint rated the package 10/10 and reports the existing unrecognized suggestion-mode configuration option.

Closes #478.

Prepared with AI assistance; reproduction and validation ran locally.

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution!

Comment thread packages/serialization/json/kiota_serialization_json/json_serialization_writer.py Outdated
@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Sep 11, 2026

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for making the changes!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

Validation passed and no blocking issues remain.

Pull request overview

Fixes JSON serialization for recursively nested lists while preserving existing validation behavior.

Changes:

  • Adds recursive nested-list dispatch.
  • Adds regression tests for supported and rejected collection types.
File summaries
File Summary
packages/serialization/json/tests/unit/test_json_serialization_writer.py Adds nested-list regression and rejection tests.
packages/serialization/json/kiota_serialization_json/json_serialization_writer.py Supports recursive nested-list serialization.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@baywet
Vincent Biret (baywet) force-pushed the codex/serialize-nested-json-arrays branch from 326ebc5 to ccbe1dd Compare September 11, 2026 17:46
@sonarqubecloud

Copy link
Copy Markdown

@baywet
Vincent Biret (baywet) enabled auto-merge (squash) September 11, 2026 17:48
@baywet
Vincent Biret (baywet) merged commit 72ac184 into microsoft:main Sep 11, 2026
53 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

[Bug] JSON Serialization Writer write_any_value does not handle nested lists

3 participants