Skip to content

Fix #1073: toJSON incorrectly wraps single table in array - #5190

Closed
0xSenior wants to merge 0 commit into
multitheftauto:masterfrom
0xSenior:master
Closed

Fix #1073: toJSON incorrectly wraps single table in array#5190
0xSenior wants to merge 0 commit into
multitheftauto:masterfrom
0xSenior:master

Conversation

@0xSenior

Copy link
Copy Markdown

Problem:

  • toJSON({ key = value }) returned '[{...}]' instead of '{...}'
  • WriteToJSONString() always called WriteToJSONArray(), wrapping all results in a JSON array even for single table arguments

Solution:

  • Check if there is exactly one argument and it is a table (LUA_TTABLE)
  • If so, serialize it directly using WriteToJSONObject() instead of wrapping it in an array via WriteToJSONArray()
  • Otherwise, fall back to existing array behavior

Files changed:

  • Client/mods/deathmatch/logic/lua/CLuaArguments.cpp
  • Server/mods/deathmatch/logic/lua/CLuaArguments.cpp

This fix maintains backward compatibility for multiple arguments and non-table single arguments.

Summary

Motivation

Test plan

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

Copilot AI lite review requested due to automatic review settings August 16, 2026 22:30

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 16, 2026 22:50
@0xSenior 0xSenior closed this Aug 16, 2026

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.

Copilot wasn't able to review any files in this pull request.

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.

2 participants