php / php/php-src

JSON_ERROR_DEPTH with JSON_PARTIAL_OUTPUT_ON_ERROR.

Open
#13,258 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: json Feature
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Hi, json_encode, when it exceeds the max depth, having the flag JSON_PARTIAL_OUTPUT_ON_ERROR, just ignores the max depth and goes on. Shouldn't be a better choice to stop at that depth, replacing by null, for example, following the "partial output" sense as with JSON_ERROR_RECURSION?
Ignoring the optional depth limit seems a bug and truncating the chain of references with null, giving a partial output seems natural.
It seems a trivial change in the sources, thank you.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing json_encode with JSON_PARTIAL_OUTPUT_ON_ERROR on data exceeding the configured depth, then trace the JSON encoding implementation in the PHP source. Done means the depth limit is respected and the output is partial, such as replacing the over-depth value with null, with regression coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.