-1

Our API and GitHub's both return JSON text content.

GitHub's API in the browser is displayed wrapped in a <pre> tag and in monospace font.

However, our API is displayed in serif font without any wrapper.

Why is it displayed in a different font when both responses are JSON?

andrewtweber
  • 24,520
  • 22
  • 88
  • 110
voku
  • 19
  • 3
  • 1
    How is this a comparision? One are square brackets and the other sample are curly ones. Or what exactly is your question? – puelo Apr 29 '16 at 21:54
  • Possible duplicate of [Pretty-Printing JSON with PHP](http://stackoverflow.com/questions/6054033/pretty-printing-json-with-php) – r3wt Apr 29 '16 at 22:30
  • op see the comment section of the accepted answer in the question link above for instructions on setting the content header and pretty printing the json. – r3wt Apr 29 '16 at 22:31

1 Answers1

5

Try refreshing the GitHub page with the Network tab open. You will see among the Response Headers:

Content-Type: application/json; charset=utf-8

(If it's a cached response then you won't see that header - try another GitHub link though and you'll see it)

GitHub is setting this ContentType header on their response. Chrome recognizes that the response is JSON, so it formats it with a <pre> tag wrapped around it to make it easier to read.

Your API is returning plain text, therefore Chrome doesn't recognize it as JSON.

andrewtweber
  • 24,520
  • 22
  • 88
  • 110
  • Ah thank you. Stupid question but thanks for the serious answer. – voku Apr 30 '16 at 17:03
  • @voku No problem, not a stupid question. Sometimes it's just hard to even know what to ask. I knew what you meant immediately and I tried to get my answer in before the question got closed – andrewtweber May 02 '16 at 16:12