plainify-loader

Convert JSON to plain object.

Usage no npm install needed!

<script type="module">
  import plainifyLoader from 'https://cdn.skypack.dev/plainify-loader';
</script>

README

plainify-loader

npm version Build Status

Convert JSON to plain object.

Sponsored by Evil Martians

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.