# json-front-matter

> Extract JSON front matter from strings and files

Latest version **1.0.0** (published 2015-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-front-matter
pnpm add json-front-matter
yarn add json-front-matter
bun add json-front-matter
```

## 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 | 2015-01-24 |
| First published | 2012-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Jordan Santell |
| Maintainers | jsantell |
| Keywords | json, front-matter, parse, yaml |

## Links

- npm: https://www.npmjs.com/package/json-front-matter
- Repository: http://github.com/jsantell/node-json-front-matter
- Homepage: https://github.com/jsantell/node-json-front-matter
- Issues: https://github.com/jsantell/node-json-front-matter/issues
- npm.io page: https://npm.io/package/json-front-matter

## 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) — 2015-01-24
- 0.1.6 — 2014-05-21
- 0.1.5 — 2014-05-15
- 0.1.4 — 2013-11-19
- 0.1.3 — 2012-07-24
- 0.1.2 — 2012-07-14
- 0.1.1 — 2012-07-01
- 0.1.0 — 2012-07-01

## README

json-front-matter
======

[![Build Status](http://img.shields.io/travis/jsantell/json-front-matter.svg?style=flat-square)](https://travis-ci.org/jsantell/json-front-matter)
[![Build Status](http://img.shields.io/npm/v/json-front-matter.svg?style=flat-square)](https://www.npmjs.org/package/json-front-matter)

Extract JSON front matter from strings and files in the style of [Jekyll's YAML Front Matter](https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter).

### Installing

* `npm install json-front-matter`

### Methods

* `parse( s )` Parses string `s`, returning an object with properties `attributes`, containing the JSON front matter, and `body` containing the rest.
* `parseFile( path, callback( err, data ))` Parses file at `path`, calling the callback upon completion with `data` object containing `attributes` and `body`, like the string parse method.

### Usage

```javascript
var fm = require('json-front-matter');

var string = '{{{ "title" : "some title", "array" : [ 1, 2, 3 ] }}} bodybodybody';
var out = fm.parse( string );

console.log( out.body ) // 'bodybodybody'
console.log( out.attributes.title ) // 'some title'
console.log( out.attributes.array ) // [ 1, 2, 3 ]
```

### File Example

See [./tests/data/test.md](https://raw.github.com/jsantell/node-json-front-matter/master/tests/data/test.md) for example of JSON Front Matter in a markdown file. The outer JSON is encapsulated via triple curly brackets. `{{{ "tags" : [ 'rock', 'paper', 'scissors' ] }}}`

### Testing

Run `node tests/runTests.js` from project root -- testing uses `nodeunit`

### License

MIT License, Copyright (c) 2012 Jordan Santell

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