3

I have a file that contains many dictionaries, each line with its own unique dictionary and there are many lines in this file.

{"text": "bla bla", "year": 1933, "price": 43}
{"text": "bla blu", "year": 1934, "price": 41}
{"text": "blu bla", "year": 1935, "price": 43}
{"text": "blu blu", "year": 1936, "price": 44}

Just wanted to emphesize that the dictionaries are not inserted into a list, this is just the way it is, each new row in the file contains a dictionary.

Indent
  • 4,675
  • 1
  • 19
  • 35
Lior Magen
  • 1,533
  • 2
  • 15
  • 33
  • If you prepend `[` and append `]`, then replace `\n` by `,` you get an array of dictionaries, wich is JSON-conform. – AlexR Nov 09 '17 at 09:03
  • JSON requires double quotes, so the dictionaries in the example are not valid JSON. – str Nov 09 '17 at 09:08
  • 2
    @str I edited the question, it's double quotes as you said and not I wrote before. – Lior Magen Nov 09 '17 at 09:25

1 Answers1

3

It's a JSON Lines text file format : http://jsonlines.org/

JSON Lines text format, also called newline-delimited JSON. JSON Lines is a convenient format for storing structured data that may be processed one record at a time. It works well with unix-style text processing tools and shell pipelines. It's a great format for log files. It's also a flexible format for passing messages between cooperating processes.

Indent
  • 4,675
  • 1
  • 19
  • 35
  • 1
    I use this format very often. It's very usefull to share complex model between differents language – Indent Nov 09 '17 at 09:40