Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON lines Mime type

Tags:

json

jsonlines

I want to know what Content-Type to set for JSON lines (http://jsonlines.org/)?

I tried searching. Its not really application/json as the entire content is not JSON (each line is).

Thanks

like image 322
codesalsa Avatar asked Aug 05 '18 00:08

codesalsa


People also ask

What is the MIME type of JSON?

text/plain was typically used for JSON, but according to IANA, the official MIME type for JSON is application/json .

Is JSON and Jsonl same?

A JSONL file is a JSON file created in the JSON Lines format. It contains plain text used to describe structured data. JSONL files are used primarily to stream structured data that should be processed one record at a time.

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.


3 Answers

As per https://github.com/wardi/jsonlines/issues/9, there is no official mime type, but a convention of application/x-ndjson. Or application/x-jsonlines. Note that this issue has been sitting there since 2015, which might suggest that jsonlines is not exactly catching fire.

like image 62
bmargulies Avatar answered Oct 27 '22 09:10

bmargulies


JSON lines is supported by some AWS services and they use application/jsonlines content type.

like image 6
alex Avatar answered Oct 27 '22 10:10

alex


I have the server return text/plain; charset=utf8 for JSON Lines files. As @bmargulies says, application/x-ndjson has limited support. At least with text/plain users can see the data in their browser (rather than being shown a download/save as dialog). Setting the charset explicitly prevents random "corruption" by (un)helpful user agents.

like image 5
Trenton Avatar answered Oct 27 '22 10:10

Trenton