Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

lucasmichot
Copy link
Contributor

@lucasmichot lucasmichot commented Sep 2, 2025

Description

This PR enhances the prettyJson helper by introducing support for JSON options, giving developers more control over JSON encoding beyond the default JSON_PRETTY_PRINT, see #56697.

Motivation

Currently, prettyJson always forces JSON_PRETTY_PRINT, without a way to adjust encoding flags. This limits use cases such as:

  • Encoding Unicode characters without escaping (JSON_UNESCAPED_UNICODE)
  • Preserving slashes (JSON_UNESCAPED_SLASHES)
  • Adding other json_encode options when needed

By making options configurable, developers can fine-tune the output according to their requirements.

Changes

  • Adds an $options parameter (default: none) to prettyJson.
  • Maintains backward compatibility with existing calls.
  • Extends test coverage to validate behavior with additional flags.

Example Usage

prettyJson(['foo' => 'bar'], JSON_UNESCAPED_UNICODE);

Testing

  • ✅ Added unit tests for custom options
  • ✅ Verified backward compatibility (no breaking changes)

Related

N/A

@lucasmichot lucasmichot force-pushed the feat/12x-prettyprint-options branch from 5a0bbab to ea284de Compare September 2, 2025 14:25
@taylorotwell taylorotwell merged commit 185d9bb into laravel:12.x Sep 2, 2025
63 checks passed
@AhmedAlaa4611
Copy link
Contributor

Why don't we add tests to both of the following files?

  • tests/Support/SupportCollectionTest.php
  • tests/Support/SupportFluentTest.php

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.

3 participants