Hi-
Is there currently a switch (header option, other parameter, or server configuration) to specify that the client wants pretty JSON out? Currently, it's all mashed together as a single line. PHP's built in json_encode() appears to format like this by default.

Thanks!
-Bronius

Comments

texas-bronius’s picture

Issue summary: View changes
Atomox’s picture

Bronius, you should be able to use plugins in the browser (Chrome does this by default) to do this, but JSON is not a format-able markup. It sounds like you're really looking for something other than JSON, or some sort of interface which collects your JSON, and alters the display. If you're consuming this service, that would be up to you to build the display, or load it into some environment that will do this for you. However, by default, this is not something that should be the responsibility of services.

Maybe someone else can chime in here on modules that could consume this service, and render it in a mode human-readable way.

texas-bronius’s picture

Hi Atomox- I appreciate your getting back to me.

To be clear, I am not referring to viewing the JSON output as pretty html rendered in the browser viewport but rather just the raw string output in Chrome > Inspector > Network. It's been a while since i'd looked at this specifically, but I am asking how we might be able to get the json output of Services module to include line breaks and whitespace for indenting, and that the native php function json_encode() seemed to have provided that out of the box.

Thanks
-Bronius

kylebrowning’s picture

Status: Active » Closed (fixed)

Its not currently support, but if you use HTTPie it will do it for you.

Silicon.Valet’s picture

It's mashed together because it takes up less space that way. One of the big advantages of JSON for REST calls over say, XML is the comparative brevity. Smaller payloads are quicker payloads.

If you want it pretty printed for convenience of debugging output, use a chrome plugin like JSONView (they'll change your life)