メモ ndjson

2022/10/10

ndjson について教えてもらったのでメモ
ndjson は Newline Delimited JSON の略

通常の JSON

[{"id": "1", "name": "hoge", "other": "Widder"},{"id": "2", "name": "fuga", "other": "Stier"},{"id": "3", "name": "piyo", "other": "Zwillinge"}]

ndjson
見てわかる通り行ごとに JSON がある
1行ごとに処理をする(fluentd や Elasticsearch など)

{"id": "1", "name": "hoge", "other": "Widder"}
{"id": "2", "name": "fuga", "other": "Stier"}
{"id": "3", "name": "piyo", "other": "Zwillinge"}

例について
中身のデータは同じだけと書き方が異なることを示した
json は配列で扱い、 ndjson は行ごとに扱う


Profile picture

Written by @honyanya web developer.
Twitter

© 2022. @honyanya