php / php/php-src

JSON pretty printing indentation using tabs or double spaces

Offen
#8,864 8 Kommentare 13 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@bukka arbeitet bereits daran.

Seit 29.7.2022.

Extension: json Feature Status: Requires RFC
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

Description

The current indentation of pretty printed JSON with json_encode() is using 4 bytes per level.
I feel we are lacking the ability to choose intendation type, i.e. for optimization.

Example:

  • Tab (1 bytes)
  • Two spaces (2 bytes)
  • Four spaces (4 bytes)

Maybe by setting a flag to either:
JSON_PRETTY_PRINT
JSON_PRETTY_PRINT_TABS
JSON_PRETTY_PRINT_DOUBLE_SPACES

I know that we can preg_replace() it the way we want. But why waste resources if we could have it at the core.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.