-
Notifications
You must be signed in to change notification settings - Fork 355
JSON streams
JSON is a very convenient format for exchanging data that can be used by many different programming languages.
A slight disadvantage of JSON is that it doesn't come with a stream format. If you need to send a large number of JSON objects from one place to another, you don't want to put them all in one JSON list, because then you have to parse the entire list before you can get at any of the objects.
However, it's really easy to impose a stream format on top of JSON. This format is not standardized, but it's obvious enough to have become common. You could call it "line-delimited JSON", "streaming JSON", or "JSON streams".
- A JSON stream is a UTF-8 encoded text file.
- Each line of the file contains a single JSON object. (Here "object" means the structure that is surrounded by
{curly braces}
, which Python would call a dictionary.) - These objects are interpreted according to the json.org standard, using existing JSON tools. The only difference from the standard is that line breaks within an object are not allowed.
Some straightforward tools for working with JSON streams appear in the conceptnet5.formats.json_stream
module.
It appears to be common to use the extension .json
on a file containing a JSON stream. This seems problematic, because the file will not parse as JSON. We recommend the extension .jsons
, and use it throughout ConceptNet.
Starting points
Reproducibility
Details