WordPress.org

Make WordPress Core

Opened 9 months ago

Last modified 9 months ago

#41998 new enhancement

REST API: Add debug mode

Reported by: Viper007Bond Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.4
Component: REST API Keywords: has-patch
Focuses: rest-api Cc:

Description

It'd be nice if I could toggle on JSON_PRETTY_PRINT for the REST API for use in development, just to make life easier. A new constant such as WP_DEBUG_REST_API that enables this could be useful that could do other things in the future.

Attached is an example implementation.

Attachments (1)

41998.patch (1.4 KB) - added by Viper007Bond 9 months ago.

Download all attachments as: .zip

Change History (5)

@Viper007Bond
9 months ago

#1 @johnbillion
9 months ago

  • Version changed from 4.8.2 to 4.4

Fun fact: JSON_PRETTY_PRINT was only introduced in PHP 5.4.

#2 @adamsilverstein
9 months ago

@Viper007Bond I've had great luck with browser extensions for viewing JSON, such as JSON Viewer for Chrome, which in addition to the pretty printing, lets you collapse/expand parts of the object tree.

#3 @Viper007Bond
9 months ago

Replying to johnbillion:

Fun fact: JSON_PRETTY_PRINT was only introduced in PHP 5.4.

Yep, but we have compatibility already in place for it: #30139

Replying to adamsilverstein:

@Viper007Bond I've had great luck with browser extensions for viewing JSON, such as JSON Viewer for Chrome, which in addition to the pretty printing, lets you collapse/expand parts of the object tree.

A similar feature is built into Firefox Developer Edition which I use but I also use the REST API client in my code editor (PHPStorm) which sadly just displays the raw response (although I can click a few times and get it formatted). Additionally passing authorization headers and POST data can be a pain in the browser.

Last edited 9 months ago by Viper007Bond (previous) (diff)
Note: See TracTickets for help on using tickets.