Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Json.php

function Json::prettify

Throws

InvalidJsonException

1 call to Json::prettify()
JsonMatches::fail in vendor/phpunit/phpunit/src/Framework/Constraint/JsonMatches.php
Throws an exception for the given compared value and test description.

File

vendor/phpunit/phpunit/src/Util/Json.php, line 33

Class

Json
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Util

Code

public static function prettify(string $json) : string {
    $decodedJson = json_decode($json, false);
    if (json_last_error()) {
        throw new InvalidJsonException();
    }
    return json_encode($decodedJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
RSS feed
Powered by Drupal