json-property-filter
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

json-property-filter

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

MIT License npm version TypeScript Build Status Coverage Status typescript-standard-style Known Vulnerabilities

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.

Package Sidebar

Install

npm i json-property-filter

Weekly Downloads

75

Version

2.0.0

License

MIT

Unpacked Size

23.1 kB

Total Files

15

Last publish

Collaborators

  • cyril.schumacher