1.1.0 • Published 5 years ago

plainify-loader v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

plainify-loader

npm version Build Status

Convert JSON to plain object.

Why?

Loader developed for usage with react-intl which can use only plain objects as messages object.

But I like structure used in counterpart.js or Rails I18n, where locales represents as nested object, but ids used by library for traversing over the locales.

Example

in

{
  "key": "value",
  "nested": {
    "other_key": "other_value"
  }
}

out

{
  "key": "value",
  "nested.other_key": "other_value"
}

Warning

The loader provides support only for values represented as strings or objects with strings values because developed for the particular usage.

Installation

npm install plainify-loader

Usage

import json from "json!plainify!./file.json";
// => returns file.json content as JSON parsed and plainified object

or you can use it with yaml-loader

import json from "json!plainify!yaml!./file.yml";
// => returns file.yml content as YAML parsed and plainified object

Contributors

Great thanks to @jumpgh for contributions.