this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/cue: prefer ndjson over ldjson

Per https://github.com/ndjson/ndjson-spec/issues/3 in 2014,
the ldjson spec (line-delimited JSON) was renamed to ndjson
(newline-delimited JSON) and so we should use the newer extension.

We already supported loading files with the ndjson extension,
but `cue import` still only supported ldjson.

Use ndjson in all the documentation and examples,
but continue to support ldjson for backwards compatibility.

Any non-encoding tests which used ldjson files now use ndjson files
for the sake of consistency.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Iff4a853ed5cfc34aaecece523782c4154e3e6e63
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199412
Reviewed-by: Matthew Sackman <matthew@cue.works>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+10 -10
+1 -1
cmd/cue/cmd/help.go
··· 518 518 json .json JSON files. 519 519 yaml .yaml/.yml YAML files. 520 520 toml .toml TOML files 521 - jsonl .jsonl/.ldjson Line-separated JSON values. 521 + jsonl .jsonl/.ndjson Line-separated JSON values. 522 522 jsonschema JSON Schema. 523 523 openapi OpenAPI schema. 524 524 pb Use Protobuf mappings (e.g. json+pb)
+3 -3
cmd/cue/cmd/import.go
··· 53 53 the following modes: 54 54 55 55 Mode Extensions 56 - json Look for JSON files (.json, .jsonl, .ldjson). 56 + json Look for JSON files (.json .jsonl .ndjson). 57 57 yaml Look for YAML files (.yaml .yml). 58 58 toml Look for TOML files (.toml). 59 59 text Look for text files (.txt). ··· 269 269 270 270 func runImport(cmd *Command, args []string) (err error) { 271 271 c := &config{ 272 - fileFilter: `\.(json|yaml|yml|toml|jsonl|ldjson)$`, 272 + fileFilter: `\.(json|yaml|yml|toml|jsonl|ndjson|ldjson)$`, 273 273 interpretation: build.Auto, 274 274 loadCfg: &load.Config{DataFiles: true}, 275 275 } ··· 289 289 case "proto": 290 290 c.fileFilter = `\.proto$` 291 291 case "json": 292 - c.fileFilter = `\.(json|jsonl|ldjson)$` 292 + c.fileFilter = `\.(json|jsonl|ndjson|ldjson)$` 293 293 case "yaml": 294 294 c.fileFilter = `\.(yaml|yml)$` 295 295 case "toml":
+4 -4
cmd/cue/cmd/testdata/script/embed_err.txtar
··· 41 41 42 42 doublestar: _ @embed(glob="**/*.json") 43 43 44 - stream: _ @embed(file=test.ldjson) 44 + stream: _ @embed(file=test.ndjson) 45 45 46 - singlestream: _ @embed(file=single.ldjson) 46 + singlestream: _ @embed(file=single.ndjson) 47 47 48 48 yamlstream: _ @embed(file=stream.yaml) 49 49 ··· 80 80 81 81 -- test.json -- 82 82 { "x": 34 } 83 - -- test.ldjson -- 83 + -- test.ndjson -- 84 84 { "x": 35 } 85 85 { "x": 36 } 86 - -- single.ldjson -- 86 + -- single.ndjson -- 87 87 { "x": 37 } 88 88 -- stream.yaml -- 89 89 1
+1 -1
cmd/cue/cmd/testdata/script/encoding_jsonl.txtar
··· 28 28 29 29 # Check that `cue import` supports all filenames too, 30 30 # both by default and when loading JSON only. 31 - # TODO(mvdan): ndjson is not supported here, but it should. 32 31 # TODO(mvdan): note that `cue import --dry-run` does not work, 33 32 # so we need to use rm and stderr checks to ensure we create the files we expect. 34 33 ··· 78 77 -- import.stderr -- 79 78 importing into input-jsonl.cue 80 79 importing into input-ldjson.cue 80 + importing into input-ndjson.cue 81 81 importing into input-one.cue
+1 -1
cue/interpreter/embed/embed.go
··· 54 54 // # Limitations 55 55 // 56 56 // The embed interpreter currently does not support: 57 - // - stream values, such as .ldjson or YAML streams. 57 + // - stream values, such as .ndjson or YAML streams. 58 58 // - schema-based decoding, such as needed for textproto 59 59 // 60 60 // # Example