I’m working on a JSON API and I want to do something like Facebook’s opengraph styling.
The opengraph style indents and breaks lines, how do you go about doing this? If you use styling through HTML or CSS the JSON can not be loaded.
I’m working on a JSON API and I want to do something like Facebook’s
Share
You can use JSON_PRETTY_PRINT which is new in PHP 5.4:
If you don’t have, or can’t upgrade to version 5.4 then you have to find some side of server-side parser.
Edit
I don’t know why I assumed you’re using PHP when you haven’t tagged it. Whatever server side language you’re using though you’ll want to send out a non-html Content-Type and use new lines and tabs to pretty print it, not HTML.