https://github.com/earobinson/jyson
A template engine for json.
https://github.com/earobinson/jyson
json jyson template
Last synced: 4 months ago
JSON representation
A template engine for json.
- Host: GitHub
- URL: https://github.com/earobinson/jyson
- Owner: earobinson
- License: mit
- Created: 2017-05-30T22:38:49.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T15:40:41.000Z (over 3 years ago)
- Last Synced: 2025-08-19T14:24:10.011Z (10 months ago)
- Topics: json, jyson, template
- Language: JavaScript
- Size: 539 KB
- Stars: 5
- Watchers: 20
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# jyson
This package lets you generate fast json templates for your apis. It lets you quickly build powerful api templates.
[](https://www.npmjs.com/package/jyson)
[](https://travis-ci.org/earobinson/jyson)
[](https://coveralls.io/github/earobinson/jyson)
[](https://www.npmjs.com/package/jyson)
## Install
```bash
npm install jyson --save
```
## Usage
jyson can create many different types of templates, for a full list of examples check out the [example tests](https://github.com/earobinson/jyson/blob/master/spec/lib/jyson/jyson.example.spec.js).
```js
const jyson = require('jyson');
const productTemplateFunction = jyson.buildTemplateFunction({
name: 'name',
tags: ['meta.tags.$'],
other: {
dogRating: 'meta.rating',
exampleMissingValue: 'notFound',
dateRan: ({ templateOpts }) => templateOpts.dateRan
}
});
const input = {
name: 'Bacon Peanut Butter “Ice Cream” for Dogs',
meta: {
rating: 10,
tags: [
'lactobacillus bulgaricus',
'enterocococcus thermophilus',
'lactobacillus acidophilus',
'bifidobacterium bifidum',
'lactobacillus casei'
],
}
};
const result = productTemplateFunction([input], {dateRan: 1496351371149});
// => [{
// name: 'Bacon Peanut Butter “Ice Cream” for Dogs',
// tags:[
// 'lactobacillus bulgaricus',
// 'enterocococcus thermophilus',
// 'lactobacillus acidophilus',
// 'bifidobacterium bifidum',
// 'lactobacillus casei'
// ],
// other: {
// dogRating: 10,
// exampleMissingValue: null,
// dateRan: 1496351371149
// }
//}]
```
## Goals
- Easy to install
- Easy to understand
- Make jyson part of the common lexicon
## Contributing
Please read through our [contributing guidelines](CONTRIBUTING.md). Included are directions
for opening issues, coding standards, and notes on development.
***
Built with ❤️ at [Hubba](https://www.hubba.com?utm_campaign=hubba_oss). Maintained with 💖 by [earobinson](https://earobinson.net).