#29435 closed enhancement (invalid)
wp_send_json() & co. should support json_encode()'s optional arguments
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.2 |
Component: | Gallery | Keywords: | has-patch close |
Focuses: | Cc: |
Description
For debugging, I want my wp_send_json_success()
call to output pretty, human readable JSON. You can do this by passing JSON_PRETTY_PRINT
as the second parameter to json_encode()
.
wp_send_json()
and the higher level functions that call it should support these optional arguments.
Attachments (4)
Change History (14)
#2
@
11 years ago
In 29435.2.patch:
Added 'Optional.' before description of new variables in docblocks as per doc standards.
#3
@
11 years ago
Thanks but oops, I noticed I also had the wrong var ($data
) in the docblock for wp_send_json()
. I copied them off some other functions.
Fixed patch incoming.
#5
in reply to:
↑ 4
@
11 years ago
Makes sense, just send status without any returned data.
Replying to Viper007Bond:
Also added
Optional.
to the$data
descriptions.
#7
follow-up:
↓ 8
@
11 years ago
- Keywords close added; dev-feedback removed
To be honest, this doesn't seem like something I find particularly necessary. It adds unnecessary complexity to a dead-simple utility function.
At most, we could pass JSON_PRETTY_PRINT when WP_DEBUG. But I'd be more inclined to just suggest a change in your debugging in such a way that your browser handles this for you — and better than just whitespace. In Chrome, there's a popular extension for turning JSON into a collapsable tree. Viewing an XHR request in the inspector also gives you a full preview that is, again, an expandable tree.
#8
in reply to:
↑ 7
@
11 years ago
Replying to nacin:
To be honest, this doesn't seem like something I find particularly necessary. It adds unnecessary complexity to a dead-simple utility function.
At most, we could pass JSON_PRETTY_PRINT when WP_DEBUG. But I'd be more inclined to just suggest a change in your debugging in such a way that your browser handles this for you — and better than just whitespace. In Chrome, there's a popular extension for turning JSON into a collapsable tree. Viewing an XHR request in the inspector also gives you a full preview that is, again, an expandable tree.
Makes sense to me, especially for debugging - and agree it adds unnecessary complexity. Wondering if any of the other predefined constants would be useful?
This seems like a useful addition, thanks!