Skip to content

feat: JSON.parse of an object or array says it is probably already parsed - #71

Merged
kommander merged 1 commit into
devfrom
new/json-parse-object
Nov 24, 2026
Merged

kommander merged 1 commit into
devfrom
new/json-parse-object

Conversation

@kommander

Copy link
Copy Markdown
Contributor

JSON.parse given an object or array throws TypeError: JSON.parse expects a string, got an object (is it already parsed?) at the call.
Why: parsing an already-parsed value is a common agent mistake; the old error (Unexpected identifier \"object\") did not say so.

…rsed

JSON.parse given a plain object or an array throws TypeError "JSON.parse expects a string, got an object (is it
already parsed?)" at the call, instead of parsing "[object Object]" or the joined elements. Other non-string values
are parsed as before.
@kommander
kommander merged commit 06adc85 into dev Nov 24, 2026
1 check passed
@kommander
kommander deleted the new/json-parse-object branch November 24, 2026 23:16
kommander added a commit that referenced this pull request Nov 25, 2026
)

JSON.parse given a plain object or an array, a value already parsed, returns it unchanged instead of #71's TypeError.
Strings and every other input parse as before.
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