Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2
Parse and generate RS-delimited JSON sequences according to draft-ietf-json-text-sequence
License
hildjj/json-text-sequence
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Parse and generate JSON text sequences as defined inRFC 7464.
JSON text sequences are nice for unambiguous JSON log files. They are resilientto many forms of damage such as truncation, multiple writers incorrectlyconfigured to write to the same file, corrupted JSON, etc. An example sequence:
␞{"d":"2014-09-22T21:58:35.270Z","value":6}␞{"d":"2014-09-22T21:59:15.117Z","value":12}Where "␞" is the ASCII "Record Separator" character (U+001E), and "" is theASCII "LINE FEED" character (U+000A), otherwise known as "\n".
npm install json-text-sequenceTo parse the format, pipe an input source into a parser stream:
import{Parser}from'json-text-sequence'importfsfrom'fs'constp=newParser().on('data',obj=>{console.log('JSON:',obj);}).on('truncated',buf=>{console.log('Truncated:',buf);}).on('invalid',buf=>{console.log('Invalid:',buf);}).on('finish',()=>{console.log('DONE');});fs.createReadStream('example.log').pipe(p);
To generate the format, create a generator, pipe its output somewhereinteresting, then write objects to the generator:
import{Generator}from'json-text-sequence'importfsfrom'fs'constg=newGenerator();g.pipe(fs.createWriteStream('example.log'));g.write({d:newDate(),count:0});
About
Parse and generate RS-delimited JSON sequences according to draft-ietf-json-text-sequence
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.