# json-flat

> Flatters any JSON properties returning an array of concatenated properties

Latest version **1.0.0** (published 2016-05-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-flat
pnpm add json-flat
yarn add json-flat
bun add json-flat
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-05-12 |
| First published | 2016-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Adrián Gómez Llorente |
| Maintainers | adgllorente |
| Keywords | json, flat, flatter, flattern |

## Links

- npm: https://www.npmjs.com/package/json-flat
- Repository: https://github.com/adgllorente/json-flat
- Issues: https://github.com/adgllorente/json-flat/issues
- npm.io page: https://npm.io/package/json-flat

## Dependencies (1)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-05-12

## README

# json-flat
Flatters any JSON properties returning an array of concatenated properties.

[![npm version](https://badge.fury.io/js/json-flat.png)](https://badge.fury.io/js/json-flat)
[![Build Status](https://travis-ci.org/adgllorente/json-flat.svg?branch=master)](https://travis-ci.org/adgllorente/json-flat)
![Dependencies status](https://david-dm.org/adgllorente/json-flat.svg)
[![Donate please](https://www.paypalobjects.com/webstatic/en_US/btn/btn_donate_74x21.png)](https://www.paypal.me/adgllorente/1)

# Usage
This module might be used from CLI or requiring it.

## From CLI
This module might be used from CLI. It parses a given JSON file and returns a list of properties concatenated. Expects these parameters:
- ``--path``: Path to a JSON file.
- ``--separator`` *(Optional)*: Separator to be used to concatenate properties

```shell
$> node json-flat --path ./test.json
foo.bar
foo.bar.string

$> node json-flat --path ./test.json --separator _
foo_bar
foo_bar_string
```

## From require
This module might be imported in other module using ``require``. It parses a given JSON Object and returns an array with all properties concatenated, for example:

```js
var jsonFlat = require('./json-flat'),
  _json = JSON.stringify({
    foo: {
      number: 1,
      bar: {
        string: 'Hello World'
      }
    }
  });

// With default separator
jsonFlat.flat(_json).forEach(function(property) {
  console.log(property);
});
// Prints:
//   foo.number
//   foo.bar.string

// With a given separator
jsonFlat.flat(_json, '_').forEach(function(property) {
  console.log(property);
});
// Prints:
//   foo_number
//   foo_bar_string
```

---
_Source: https://npm.io/package/json-flat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
