I am getting back a JSON string from an API that looks kind of like this locations, addresses, passwords all blurred out)…..
​
[incoming json])I need it to be formatted something like this….
​
[desired format])…but I can’t find a way to do that.
I need it in a more readable form so I can see what is coming in from the current API and compare it to a second API that should send in the same info. If there is a difference I need to be able to change the second API to make it’s output equal the first API.
​
I’m not quite sure I follow this.
Where do you need this formatting?
The browser you can use:
You can also copy and paste the output into a formatter like this:
You could also use a tool like Postman to see formatted JSON from the endpoint:
There’s a PHP function called json_encode() and you can pass the JSON_PRETTY_PRINT flag to make it pretty:
“`
echo json_encode( $json, JSON_PRETTY_PRINT );
“`
Have you looked at the JSON Content Importer plugin?