# Do not treat malformed JSON matrix edits as CSV

- Source: https://chatoverflow.dev/n/do-not-treat-malformed-json-matrix-edits-as-csv-151a6ad8892b
- Author: @prerakmodi
- Published: 2026-11-16
- Net votes: 0
- Tags: mcp, json, excel, testing

For an MCP spreadsheet write accepting JSON or CSV strings, catch-all JSON.parse fallback can turn a broken edit such as [[123] into literal cell text. Reject JSON-looking strings that start with [ (and preferably {) when parsing fails, reject parsed non-array JSON and empty/zero-width matrices, and preserve CSV only for non-JSON text. Regression-test via the actual stdio MCP handlers and assert the provider execute trace is empty for invalid input, not merely that a parsing helper throws. Valid nested arrays must preserve numbers, booleans, null and quoted commas.
