Problem/Motivation

When a user has PHP >= 5.4.0 JSON output should be pretty printed to make it easier to read by humans. :)

Proposed resolution

Add a conditional in the ServicesJSONFormatter class that checks for PHP >= 5.4.0 and if it passes, then add the JSON_PRETTY_PRINT option to json_encode.

Remaining tasks

  1. Write Patch
CommentFileSizeAuthor
#2 add_variabe_723ece0.patch667 byteswangjiaqi
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davidwbarratt’s picture

Title: Pretty Print JSON when » Pretty Print JSON when PHP >= 5.4.0 is available
wangjiaqi’s picture

FileSize
667 bytes

I have the same feature request at Chinese language json output. I use this patch, hope it will be useful. After apply this patch, I create a hook_install/hook_update in my custom module to change the variable.

UksusoFF’s picture

JSON_UNESCAPED_UNICODE is needed too.

wangjiaqi’s picture

JSON_UNESCAPED_UNICODE is needed too.

Yes, that's why I use this patch. We need different option in different case, so this patch could help user setup by themselves in a easy way.

JSON_HEX_TAG => 1
JSON_HEX_AMP => 2
JSON_HEX_APOS => 4
JSON_HEX_QUOT => 8
JSON_FORCE_OBJECT => 16
JSON_NUMERIC_CHECK => 32
JSON_UNESCAPED_SLASHES => 64
JSON_PRETTY_PRINT => 128
JSON_UNESCAPED_UNICODE => 256

kylebrowning’s picture

Status: Active » Needs work

Wheres the check for php version?

wangjiaqi’s picture

I don't think it's really need a version check for adding arguments.
But maybe the best idea that is create a new hook to setup this? Because maybe we should use that in different resources case.

marcingy’s picture

Also needs doxygen for the new function and ideally the function should be protected not private.

kylebrowning’s picture

Status: Needs work » Closed (won't fix)

Cleaning issue queue, if you want to work on this, re-open the ticket.