zend-json icon indicating copy to clipboard operation
zend-json copied to clipboard

Ability to change json_encode() options

Open anton-kotik opened this issue 9 years ago • 3 comments

There is no way to modify json_encode() encode options except JSON_PRETTY_PRINT. For example we can't enable JSON_UNESCAPED_UNICODE or disable default options.

Extending the base class Zend\Json\Json as workaround creates another problems - can't use JsonRenderer with another Json encoder, Zend\Json\Json only: https://github.com/zendframework/zend-view/blob/master/src/Renderer/JsonRenderer.php#L127-L170

anton-kotik avatar Sep 19 '16 20:09 anton-kotik

Hi,

Our immediate problem is that we need to pass JSON_FORCE_OBJECT to json_encode. This is because the JSON output an API document that expects an integer-indexed-object, rather an array.

Is there any objection to us adding this functionality and submitting a pull request with it in?

JohnWhitleyEkkoSense avatar Sep 17 '19 07:09 JohnWhitleyEkkoSense

Seems acceptable, although since JSON_THROW flags are now existing directly in core, this component can most likely be removed from your codebase instead...

Ocramius avatar Sep 17 '19 07:09 Ocramius

This repository has been closed and moved to laminas/laminas-json; a new issue has been opened at https://github.com/laminas/laminas-json/issues/4.

weierophinney avatar Dec 31 '19 21:12 weierophinney