https://github.com/snowpact/gatsby-yaml-full-jsonify
Parses Objects into strings
https://github.com/snowpact/gatsby-yaml-full-jsonify
gatsby-yaml jsonify parse yaml
Last synced: 8 months ago
JSON representation
Parses Objects into strings
- Host: GitHub
- URL: https://github.com/snowpact/gatsby-yaml-full-jsonify
- Owner: snowpact
- Created: 2021-02-23T08:02:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T12:38:53.000Z (about 5 years ago)
- Last Synced: 2025-02-19T12:53:18.667Z (over 1 year ago)
- Topics: gatsby-yaml, jsonify, parse, yaml
- Language: JavaScript
- Size: 58.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gatsby-yaml-full-jsonify
Plugin for `gatsby-transformer-yaml-full` to parse json parseable strings.
## Install
```bash
$ npm install gatsby-yaml-full-jsonify gatsby-transformer-yaml-full
```
## Configure
```javascript
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: 'gatsby-transformer-yaml-full',
options: {
plugins: [
{
resolve: 'gatsby-yaml-full-jsonify'
}
],
},
},
// ...
],
}
```
## Usage
Use the `!jsonify` tag before a string to parse it into a parseable json string. The string can be multiline or one line.
You can omit double quotes for keys, but not for values.
### Example
#### YAML file
```yaml
# post.yaml
title: Blog post
config: !jsonify |
string: "value"
number: 2
object: { key: "value" }
array: ["1", 2]
data: !jsonify 'key: "value"'
```
#### Returning object
```javascript
{
title: 'Blog post',
config: '{ \"string\": \"value\", \"number\": 2, \"object\": { \"key\": \"value\" }, \"array\": [\"1\", 2]}',
data: '{ \"key\": \"value\"}'
}
```