Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
- Write Patch
Comment | File | Size | Author |
---|---|---|---|
#2 | add_variabe_723ece0.patch | 667 bytes | wangjiaqi |
Comments
Comment #1
davidwbarratt CreditAttribution: davidwbarratt commentedComment #2
wangjiaqi CreditAttribution: wangjiaqi commentedI 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.
Comment #3
UksusoFF CreditAttribution: UksusoFF commentedJSON_UNESCAPED_UNICODE is needed too.
Comment #4
wangjiaqi CreditAttribution: wangjiaqi commentedYes, 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
Comment #5
kylebrowning CreditAttribution: kylebrowning commentedWheres the check for php version?
Comment #6
wangjiaqi CreditAttribution: wangjiaqi commentedI 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.
Comment #7
marcingy CreditAttribution: marcingy commentedAlso needs doxygen for the new function and ideally the function should be protected not private.
Comment #8
kylebrowning CreditAttribution: kylebrowning commentedCleaning issue queue, if you want to work on this, re-open the ticket.