Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the correct MIME Type for JSON? [duplicate]

Tags:

json

php

Possible Duplicate:
What is the correct JSON content type?

I have problem on json it is only displaying " Content-Type: text/html" I am testing on localhost and my online code is

header('Access-Control-Allow-Origin: *');

header('Content-Type: application/javascript');
//header('Content-type: text/javascript');
//header('Content-type: application/json');
like image 553
user1709424 Avatar asked Sep 30 '12 07:09

user1709424


People also ask

Which of the following MIME type is the unofficial one for JSON?

The unofficial MIME type " text/json " or the content-type " text/javascript " are also supported for legacy reasons by many service providers, browsers, servers, web applications, libraries, frameworks, and APIs.

What is application JSON type?

Abstract JavaScript Object Notation (JSON) is a lightweight, text-based, language-independent data interchange format. It was derived from the ECMAScript Programming Language Standard. JSON defines a small set of formatting rules for the portable representation of structured data.

What is MIME type in REST API?

A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.


2 Answers

use this

header('Content-type: application/json');

for JSON data

like image 173
Yogesh Suthar Avatar answered Sep 20 '22 16:09

Yogesh Suthar


The application/json Media Type for JavaScript Object Notation (JSON)

header('Content-type: application/json');

chech this from IANA

good read:

Application Media Types

like image 25
Database_Query Avatar answered Sep 22 '22 16:09

Database_Query