final public function printJson(
        $prettyPrint = true,
        $depth = 512)
    {
        // NOTE: These options are important. For display purposes, we don't
        // want escaped slashes or `\uXXXX` hex versions of UTF-8 characters.
        $options = ($prettyPrint ? JSON_PRETTY_PRINT : 0) | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
        $json = $this->asJson($options, $depth); // Throws.
        if ($prettyPrint && PHP_EOL !== "\n") {
            // PHP's JSON pretty-printing uses "\n" line endings, which must be
            // translated for proper display if that isn't the system's style.
            $json = str_replace("\n", PHP_EOL, $json);
        }
        echo $json.PHP_EOL;
    }
final public function printJson(
        $prettyPrint = true,
        $depth = 512)
    {
        // NOTE: These options are important. For display purposes, we don't
        // want escaped slashes or `\uXXXX` hex versions of UTF-8 characters.
        $options = ($prettyPrint ? JSON_PRETTY_PRINT : 0) | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
        $json = $this->asJson($options, $depth); // Throws.
        if ($prettyPrint && PHP_EOL !== "\n") {
            // PHP's JSON pretty-printing uses "\n" line endings, which must be
            // translated for proper display if that isn't the system's style.
            $json = str_replace("\n", PHP_EOL, $json);
        }
        echo $json.PHP_EOL;
    }
final public function printJson ( $ prettyPrint = true , $ depth = 512 ) { // NOTE: These options are important. For display purposes, we don't // want escaped slashes or `\uXXXX` hex versions of UTF-8 characters. $ options = ( $ prettyPrint ? JSON_PRETTY_PRINT : 0 ) | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ; $ json = $ this -> asJson ( $ options , $ depth ) ; // Throws. if ( $ prettyPrint && PHP_EOL !== "\n" ) { // PHP's JSON pretty-printing uses "\n" line endings, which must be // translated for proper display if that isn't the system's style. $ json = str_replace ( "\n" , PHP_EOL , $ json ) ; } echo $ json . PHP_EOL ; }
Print a processed representation of this object instance's data as JSON.

This helper is provided as a quick and easy debug feature, instead of
having to manually write something like `var_dump($item->asJson())`.

And it's also a much better alternative than PHP's common but totally
unreadable `var_dump($item->asArray())` or `var_dump($item)` techniques.

You can even take advantage of chained operations, if you are 100% sure
that NONE of the properties along the way are `NULL`. An example of doing
that would be `$container->getItems()[0]->getUser()->printJson()`.
However, such code is ONLY recommended for quick debug tests, but not
for actual production use, since you should always be handling any `NULL`
properties along the way (unless you enjoy random errors whenever a
particular property along the chain happens to be missing from the
object's internal JSON data value storage).

Please read the description of `asJson()` if you want more information
about how the internal JSON conversion process works.

@param bool $prettyPrint Use whitespace to nicely format the data.
Defaults to `TRUE` since we assume that you want
human readable output while debug-printing.
@param int  $depth       Maximum JSON depth. Encoding fails if set too
low. Can almost always safely be left at `512`
(default).

@throws LazyJsonMapperException If there are any conversion problems.

@see LazyJsonMapper::exportObjectDataCopy()
@see LazyJsonMapper::asStdClass()
@see LazyJsonMapper::asArray()
@see LazyJsonMapper::asJson()
@see LazyJsonMapper::printPropertyDescriptions()
Print a processed representation of this object instance s data as JSON .