Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Json Laravel Package

zendframework/zend-json

Convenience utilities for encoding PHP data to JSON and decoding JSON back to native types, including helpers for advanced cases. Note: this Zend Framework repository was abandoned on 2019-12-31; development continues as laminas/laminas-json.

View on GitHub
Deep Wiki
Context7

Basic Usage

Usage of zend-json involves using two public static methods: Zend\Json\Json::encode() and Zend\Json\Json::decode().

// Decode a JSON value to PHP:
$phpNative = Zend\Json\Json::decode($encodedValue);

// Encode a PHP value to JSON:
$json = Zend\Json\Json::encode($phpNative);

ext/json

By default, the above two calls will proxy to the json_decode() and json_encode() functions of ext/json, which is bundled in default installations of PHP. Using zend-json, however, ensures that the functionality works regardless of whether or not the extension is available. Additionally, the component provides some features not found in ext/json, such as encoding native JSON expressions, communicating class inheritance, and customizations around pretty printing.

Pretty-printing JSON

Sometimes, it may be hard to explore JSON data generated by Zend\Json\Json::encode(), since it has no spacing or indentation. In order to make it easier, Zend\Json\Json allows you to pretty-print JSON data in the human-readable format with Zend\Json\Json::prettyPrint().

// Encode it to return to the client:
$json = Zend\Json\Json::encode($phpNative);
if ($debug) {
    echo Zend\Json\Json::prettyPrint($json, array('indent' => ' '));
}

The second, optional, argument to Zend\Json\Json::prettyPrint() is an option array. Option indent allows providing an indentation string; by default, it uses four spaces.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport