Skip to content

Commit a988cd9

Browse files
committed
Updating JSON doc: NDJSON spec deprecated, prefer JSON Lines
1 parent 779b263 commit a988cd9

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

pkg/yqlib/doc/usage/convert.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ will output
125125
{"whatever":"cat"}
126126
```
127127

128-
## Roundtrip NDJSON
129-
Unfortunately the json encoder strips leading spaces of values.
130-
128+
## Roundtrip JSON Lines / NDJSON
131129
Given a sample.json file of:
132130
```json
133131
{"this": "is a multidoc json file"}
@@ -147,7 +145,7 @@ will output
147145
```
148146

149147
## Roundtrip multi-document JSON
150-
The NDJSON parser can also handle multiple multi-line json documents in a single file!
148+
The parser can also handle multiple multi-line json documents in a single file (despite this not being in the JSON Lines / NDJSON spec). Typically you would have one entire JSON document per line, but the parser also supports multiple multi-line json documents
151149

152150
Given a sample.json file of:
153151
```json
@@ -229,7 +227,7 @@ will output
229227
{"a number":4}
230228
```
231229

232-
## Decode NDJSON
230+
## Decode JSON Lines / NDJSON
233231
Given a sample.json file of:
234232
```json
235233
{"this": "is a multidoc json file"}

pkg/yqlib/json_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,14 @@ var jsonScenarios = []formatScenario{
216216
scenarioType: "encode",
217217
},
218218
{
219-
description: "Roundtrip NDJSON",
220-
subdescription: "Unfortunately the json encoder strips leading spaces of values.",
221-
input: sampleNdJson,
222-
expected: expectedRoundTripSampleNdJson,
223-
scenarioType: "roundtrip-ndjson",
219+
description: "Roundtrip JSON Lines / NDJSON",
220+
input: sampleNdJson,
221+
expected: expectedRoundTripSampleNdJson,
222+
scenarioType: "roundtrip-ndjson",
224223
},
225224
{
226225
description: "Roundtrip multi-document JSON",
227-
subdescription: "The NDJSON parser can also handle multiple multi-line json documents in a single file!",
226+
subdescription: "The parser can also handle multiple multi-line json documents in a single file (despite this not being in the JSON Lines / NDJSON spec). Typically you would have one entire JSON document per line, but the parser also supports multiple multi-line json documents",
228227
input: sampleMultiLineJson,
229228
expected: roundTripMultiLineJson,
230229
scenarioType: "roundtrip-multi",
@@ -246,13 +245,13 @@ var jsonScenarios = []formatScenario{
246245
scenarioType: "roundtrip-ndjson",
247246
},
248247
{
249-
description: "Decode NDJSON",
248+
description: "Decode JSON Lines / NDJSON",
250249
input: sampleNdJson,
251250
expected: expectedNdJsonYaml,
252251
scenarioType: "decode-ndjson",
253252
},
254253
{
255-
description: "Decode NDJSON, maintain key order",
254+
description: "Decode JSON Lines / NDJSON, maintain key order",
256255
skipDoc: true,
257256
input: sampleNdJsonKey,
258257
expected: expectedJsonKeysInOrder,

0 commit comments

Comments
 (0)