json-property-filter

JavaScript library and application to filter a JSON object by including and excluding properties.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
json-property-filter
1102.0.03 years ago7 years agoMinified + gzip package size for json-property-filter in KB

Readme

json-property-filter
JavaScript library and application to filter a JSON object by including and excluding properties.

!MIT Licenselicense-imagelicense-url !npm versionnpmjs-imagenpmjs-url !TypeScripttypescript-imagetypescript-url !Build Statustravis-imagetravis-url !Coverage Statuscoveralls-imagecoveralls-url !typescript-standard-stylestandard-imagestandard-url !Known Vulnerabilitiessnyk-imagesnyk-url
json-property-filter is a JavaScript library, developed in TypeScript, providing a function to include and/or exclude JSON properties. In addition to providing a function, an executable is available to filter a JSON file.
The library can also be from a Web page: the generated code is ES5 compatible.

Getting Started

Usage

To install to using npm package manager:
npm install json-property-filter

After installation, You can use the library this way:
import * as jsonPropertyFilter from "json-property-filter";

const source = { key: "value" };
const filters = ["**"];
const result = jsonPropertyFilter.apply(source, filters);

If you want to have to have a quick overview of all features of this library, take a look at the unit tests or on RunKit website.

Command-Line

You have possibility to run in command-line this library without create a small TypeScript file. This executable provides all the options that are available at the code level. To see all the options, run the following line:
json-property-filter --help

To filter a JSON file and produce a filtered JSON file containing only message and timestamp properties, the following options are used:
json-property-filter --in "source.json" --out "destination.json" --filters "message" --filters "timestamp"

To filter a JSON file and display the result formatted with 4 spaces in the console, the following options are used:
json-property-filter --in "source.json" --filters "message" --filters "timestamp" --pretty --pretty-space 4

License

This project is licensed under the MIT License - see the LICENSE file for details.