Skip to content

Conversation

@DjordyKoert
Copy link
Contributor

Q A
Branch? 7.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #...
License MIT

Using the symfony/json-streamer component on an object which contains a list of self (list<int, self>, self[]) generates invalid JSON.

This happens because the generated code does not yield a comma (,) for the first entry in the list and instead outputs an additional comma at the end of the list.

A class like:

class Dummy
{
    /** @var Dummy[] */
    public array $dummies = [];
}

Currently outputs invalid JSON:

{"dummies":[{"dummies":[]}{"dummies":[]},{"dummies":[]},]}

This PR fixes the above example to output valid JSON:

{"dummies":[{"dummies":[]},{"dummies":[]},{"dummies":[]}]}

@carsonbot carsonbot added this to the 7.4 milestone Dec 2, 2025
@carsonbot carsonbot changed the title [JsonStreamer] fix invalid json output for list of self [JsonStreamer] fix invalid json output for list of self Dec 2, 2025
@DjordyKoert DjordyKoert requested a review from stof December 2, 2025 14:54
@DjordyKoert DjordyKoert force-pushed the fix-json-streamer branch 2 times, most recently from 01a7ad6 to 9b2b944 Compare December 2, 2025 15:55
@DjordyKoert DjordyKoert requested a review from mtarld December 2, 2025 15:59
Copy link
Contributor

@mtarld mtarld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch @DjordyKoert 🙂

@nicolas-grekas
Copy link
Member

Thank you @DjordyKoert.

@nicolas-grekas nicolas-grekas merged commit 0834f9a into symfony:7.4 Dec 5, 2025
This was referenced Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants