# grunt-json-to-object

> Reads pure JSON data from a file and creates a Javascript file holding an object with the data

Latest version **0.1.2** (published 2015-08-03) · 0 weekly downloads

## Install

```sh
npm install grunt-json-to-object
pnpm add grunt-json-to-object
yarn add grunt-json-to-object
bun add grunt-json-to-object
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2015-08-03 |
| First published | 2015-07-31 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Peter Klein |
| Maintainers | letsmakesense |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-json-to-object
- Repository: https://github.com/letsmakesense/grunt-json-to-object
- Issues: https://github.com/letsmakesense/grunt-json-to-object/issues
- npm.io page: https://npm.io/package/grunt-json-to-object

## Recent versions

- 0.1.2 (latest) — 2015-08-03
- 0.1.1 — 2015-07-31
- 0.1.0 — 2015-07-31

## README

# grunt-json-to-object

> Reads pure JSON data from a file and creates a Javascript file holding an object with the data

## Getting Started
This plugin requires Grunt `~0.4.5`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-json-to-object --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-json-to-object');
```

## The "json_to_object" task

### Overview
In your project's Gruntfile, add a section named `json_to_object` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
  json_to_object: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});
```

### Options

#### options.varname
Type: `String`
Default value: `jsonObj`

A string value that is used as the variable name for the resulting Javascript object.

### Usage Examples

#### Default Options
In this example, the default options are used to create a Javascript file with an object `jsonObj` exposed to the global namespace.

```js
grunt.initConfig({
  json_to_object: {
    options: {},
    files: {
      'dest/json-data.js': ['src/json-data-1.json', 'src/json-data-2.json'],
    },
  },
});
```

#### Custom Options
In this example, custom options are used to create a Javascript file with an object `fooObj` exposed to the global namespace.

```js
grunt.initConfig({
  json_to_object: {
    options: {
      varname: 'fooObj'
    },
    files: {
      'dest/json-data.js': ['src/json-data-1.json', 'src/json-data-2.json'],
    },
  },
});
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History
0.1.1 Removed IntelliJ files, updated .gitignore and README.md
0.1.2 Refactored handling of multiple input files

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