You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specification_draft2.md
+8-16Lines changed: 8 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# LDJSON - Line delimited JSON
1
+
# NDJSON - Newline delimited JSON
2
2
3
3
# Draft 2 (2013-07-27)
4
4
@@ -10,7 +10,7 @@ A standard for delimiting JSON in stream protocols (such as \[[TCP]\]).
10
10
11
11
There is currently no standard for transporting JSON within a stream protocol, apart from \[[Websockets]\], which is unnecessarily complex for non-browser applications.
12
12
13
-
There were numerous possibilities for JSON framing, including counted strings and non-ASCII delimiters (DLE STX ETX or Websocket�s 0xFFs).
13
+
There were numerous possibilities for JSON framing, including counted strings and non-ASCII delimiters.
14
14
15
15
The primary use case for LDJSON is an unending stream of JSON objects, delivered at variable times, over TCP, where each object needs to be processed as it arrives. e.g. a stream of stock quotes or chat messages.
16
16
@@ -32,41 +32,33 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S
32
32
33
33
### 3.1 Sending
34
34
35
-
Each JSON object MUST be written to the stream followed by the newline character 0x0A. The JSON objects MUST NOT contain newlines or carriage returns.
35
+
Each JSON object MUST be written to the stream followed by the newline character `\n` (0x0A). The newline charater MAY be preceeded by a carriage return `\r` (0x0D). The JSON objects MUST NOT contain newlines or carriage returns.
36
36
37
37
All serialized data MUST use the UTF8 encoding.
38
38
39
39
### 3.2 Receiving
40
40
41
-
The receiver MUST accept newline as line delimiter: �0x0A� (Unix)
41
+
The receiver MUST accept newline as line delimiter`\n` (0x0A) as well as carriage return and newline `\r\n` (0x0D0A). The receiver SHOULD silently ignore empty lines, e.g. `\n\n`.
42
42
43
43
#### 3.2.1 Trivial Implementation
44
44
45
45
A simple implementation is to accumulate received lines. Every time a line ending is encountered, an attempt MUST be made to parse the accumulated lines into a JSON object.
46
46
47
47
If the parsing of the accumulated lines is successful, the accumulated lines MUST be discarded and the parsed object given to the application code.
48
48
49
-
If the amount of unparsed, accumulated characters exceeds 16MiB the receiver MAY close the stream. Resource constrained devices MAY close the stream at a lower threshold, though they MUST accept at least 1KiB.
50
-
51
-
#### 3.2.2 Other Implementations
52
-
53
-
Alternate, more efficient, implementations are possible using a custom JSON parser.
54
-
55
-
The reference NodeJS/Javascript implementation can be found on github.
56
-
57
49
### 3.3 MIME Type and File Extensions
58
50
59
-
When using HTTP/email the MediaType \[[RFC4288]\] for Line Delimited JSON SHOULD be _application/x-ldjson_.
51
+
The MediaType \[[RFC4288]\] for Line Delimited JSON SHOULD be _application/x-ndjson_.
60
52
61
-
When saved in a file, the file extension SHOULD be _.ldjson_ or _.ldj_
53
+
When saved in a file, the file extension SHOULD be _.ndjson_.
62
54
63
55
## 4. Copyright
64
56
65
57
This specification is copyrighted by the authors named in section 4.1. It is free to use for any purposes commercial or non-commercial.
66
58
67
59
### 4.1 Authors
68
60
69
-
The following authors are responsible for the LDJSON core-specification:
61
+
The following authors are responsible for the NDJSON core-specification:
70
62
71
63
~~~~
72
64
Thorsten Hoeger
@@ -86,7 +78,7 @@ Jim Wilson
86
78
### 4.2 Contact
87
79
88
80
This specification and any related work is located at <https://github.com/ldjson>.
89
-
Discussion and help can be found on the LDJSON Google group located at <https://groups.google.com/d/forum/ldjson>
81
+
Discussion and help can be found on the issues page.
0 commit comments