payloadcms/payload

JSON field with array of arrays becomes array with a single object when any other field is modified via the API

Opened this issue · 0 comments

Describe the Bug

I have a document on Payload CMS. It has two fields on it, a select field, and a json field.

The JSON field contains an array of arrays, or more precisely [number, number][]. For example:

[[100, 200]]

I've made a small change in the list view to make it quicker to make certain changes to records. This uses the API to update it, and doesn't touch the json field.

However, whenever I use the API to touch a document, the JSON field value changes. The example above becomes:

[
  {
    "0": 100,
    "1": 200
  }
]

Link to the code that reproduces this issue

https://github.com/SethFalco/payload-cms-sandbox-2

Reproduction Steps

  1. Run the application. (It's configured to use SQLite.)
  2. Create a record for Custom Type.
    • Doesn't matter what you set for status.
    • For timestamps, you must specify an array of arrays. For example: [[100, 200]]
  3. Go to the list view.
  4. Select the drop-down, and select the option that is already current value.
  5. Now click into the record that you just modified the status for.
  6. Observe that the value of the timestamps field has changed.

Which area(s) are affected? (Select all that apply)

db-mongodb

Environment Info

Binaries:
  Node: 22.16.0
  npm: 11.6.0
  Yarn: 4.9.4
  pnpm: 10.6.5
Relevant Packages:
  payload: 3.56.0
  next: 15.4.4
  @payloadcms/email-nodemailer: 3.56.0
  @payloadcms/graphql: 3.56.0
  @payloadcms/next/utilities: 3.56.0
  @payloadcms/payload-cloud: 3.56.0
  @payloadcms/richtext-lexical: 3.56.0
  @payloadcms/translations: 3.56.0
  @payloadcms/ui/shared: 3.56.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Debian 6.12.41-1 (2025-08-12)
  Available memory (MB): 96204
  Available CPU cores: 22