---
name: "Mojolicious::Plugin::JsonConfig"
section: "3pm"
platform: "linux"
package: "libmojolicious-perl"
version: "0.999926-1+squeeze2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/Mojolicious::Plugin::JsonConfig"
---

# Mojolicious::Plugin::JsonConfig(3pm)

JSON Configuration Plugin

## NAME

Mojolicious::Plugin::JsonConfig - JSON Configuration Plugin

## SYNOPSIS

```
    # myapp.json
    {
        "foo"       : "bar",
        "music_dir" : "<%= app->home->rel_dir('music') %>"
    }
    # Mojolicious
    $self->plugin('json_config');
    # Mojolicious::Lite
    plugin 'json_config';
    # Reads myapp.json by default and puts the parsed version into the stash
    my $config = $self->stash('config');
    # Everything can be customized with options
    my $config = plugin json_config => {
        file      => '/etc/myapp.conf',
        stash_key => 'conf'
    };
```

## DESCRIPTION

Mojolicous::Plugin::JsonConfig is a JSON configuration plugin that preprocesses it's input with Mojo::Template.

The application object can be accessed via `$app` or the `"app"` helper.

## OPTIONS

### "default"

```
    # Mojolicious::Lite
    plugin json_config => {default => {foo => 'bar'}};
```

### "file"

```
    # Mojolicious::Lite
    plugin json_config => {file => 'myapp.conf'};
    plugin json_config => {file => '/etc/foo.json'};
```

By default `"myapp.json"` is searched in the application home directory.

### "stash\_key"

```
    # Mojolicious::Lite
    plugin json_config => {stash_key => 'conf'};
```

### "template"

```
    # Mojolicious::Lite
    plugin json_config => {template => {line_start => '.'}};
```

## METHODS

Mojolicious::Plugin::JsonConfig inherits all methods from Mojolicious::Plugin and implements the following new ones.

### "register"

```
    $plugin->register;
```

Register plugin hooks in Mojolicious application.

## SEE ALSO

Mojolicious, Mojolicious::Guides, \<http://mojolicious.org\>.
