1

How can I return pretty json from the REST API ?

When I query though curl, I receive one long string

curl http://foo.my.salesforce.com/services/data  
[{"version":"20.0","label":"Winter '11","url":"/services/data/v20.0"},{"version":"21.0","label":"Spring '11","url":"/services/data/v21.0"},{"version":"22.0","label":"Summer '11","url":"/services/data/v22.0"},{"version":"23.0","label":"Winter '12","url":"/services/data/v23.0"},{"version":"24.0","label":"Spring '12","url":"/services/data/v24.0"},{"version":"25.0","label":"Summer '12","url":"/services/data/v25.0"},{"version":"26.0","label":"Winter '13","url":"/services/data/v26.0"},{"version":"27.0","label":"Spring '13","url":"/services/data/v27.0"},{"version":"28.0","label":"Summer '13","url":"/services/data/v28.0"}]

I want the string to be more human readable.

I have tried using pretty=true because that works in other REST API's that I have used in the past.

curl http://foo.my.salesforce.com/services/data?pretty=true

http://www.salesforce.com/us/developer/docs/api_rest/

1
  • why use curl when you have REST utility in workbench?Have you tried workbench? Aug 9, 2013 at 22:07

2 Answers 2

6

-H "Authorization: Bearer access_token " -H "X-PrettyPrint:1"

After access token use -H "X-PrettyPrint:1" to get the result with formatted JSON

www.salesforce.com/us/developer/docs/api_rest/Content/quickstart_code.htm

Refer the link above to understand more

1

All JSON looks like this - regardless of platform... try a JSON Chrome Extension and maybe a REST Console extension

2
  • Thanks for the extension recommendation. I've worked with api's that have a pretty option. It sounds like that is not the norm.
    – spuder
    Aug 9, 2013 at 21:30
  • 1
    You can also paste the output into jsonlint.com. It does some formatting for you Aug 9, 2013 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .