rx-to-json
RxJS 5 operator to write data into a JSON file
Work in both JavaScript and TypeScript
Installation
npm install rx-to-json
Use
Import this library and it will add toJSON
operator to the rxjs Observable
class.
public toJSON(path: string, options?: any): Observable
Parameters:
- path: JSON file path
- options: optional configuration for the JSON creation
- header: JSON header. Default:
[
- footer: JSON footer. Default:
]
- header: JSON header. Default:
Example
Generate a JSON file from data flow:
;;let data =id: 1 name: 'Mike'id: 2 name: 'Tommy';Observable;// output file:// [{"id":1,"name":"Mike"},{"id":2,"name":"Tommy"}]
Download data from a PostgreSQL dadtabase and save it as a JSON file:
;;let db = 'connection string';db;
License
MIT