How to improve readability of MWS JSON query outputs


Problem: when logged in to MWS as an administrator, the example queries (for instance, jobs & nodes) provide JSON output that runs together and is difficult to read without copying it and running it through a formatting tool.

Example:

{"totalCount":85,"resultCount":85,"results":[{"arrayIndex":null,"arrayMasterName":null,"attributes":["checkpoint"],"blocks":[],"bypassCount":2,"cancelCount":0,"commandFile":null,"commandLineArguments":null,"completionCode":0,"cpuTime":0,"credentials":

Is there a way to get this to display more cleanly/legibly?

 

Solution: you have two options for dealing with the raw JSON emitted by MWS.

1) add "&pretty=true to the end of the address. Example:

$ curl -u moab-admin:changeme! -o - http://mws-server.internal:8080/mws/rest/jobs?api-version=3\&pretty=true

This will still provide a flat-text output, but with newlines and indentation for readabilty.

 

2) Install a browser extension/plug-in for JSON. Simply doing a web search for those terms will offer up a number of them to try. Browser extensions can be useful for things like syntax highlighting, collapsing of nodes, line numbers, and validation.

Last update:
2017-05-13 03:38
Author:
Rick McKay
Revision:
1.0
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.