npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-properties-to-json

v0.6.0

Published

Converts java property files to JSON files.

Downloads

4,954

Readme

grunt-properties-to-json

Build Status dependency Status devDependency Status

A grunt plugin for converting java property files to JSON files.

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-properties-to-json --save-dev

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

grunt.loadNpmTasks('grunt-properties-to-json');

Usage

With the following config, each .properties file in src will be converted to json and will be saved as a .json file in the same directory as the property file.

grunt.initConfig({
    propertiesToJSON: {
        main: {
            src: ['path/to/properties/files', 'another/path/to/properties/files']
        }
    }
});

It is also possible to define a destination folder for the generated json files:

grunt.initConfig({
    propertiesToJSON: {
        main: {
            src: ['path/to/properties/files', 'another/path/to/properties/files'],
            dest: 'tmp'
        }
    }
});

Split keys by a separator

You can split keys in the property files by using the splitKeysBy option (a string or regular expression). With this option the keys in the property files will be splitted by the given string or regular expression and used as nested keys in the JSON output.

grunt.initConfig({
    propertiesToJSON: {
        main: {
            src: ['path/to/properties/files', 'another/path/to/properties/files'],
            dest: 'tmp',
            options: {
                splitKeysBy: '.'
            }
        }
    }
});

Include and/or exclude keys

You can explicitly include and/or exclude namespaces, effectively whitelisting or blacklisting. For each option, provide a string, regular expression or an array of strings and regular expressions. If both options are used, exclusions are applied first, then inclusions. If you combine this option with splitKeysBy you can include and/or exclude nested keys by respectively setting the deepInclude or deepExclude option to true.

grunt.initConfig({
    propertiesToJSON: {
        main: {
            src: ['path/to/properties/files', 'another/path/to/properties/files'],
            dest: 'tmp',
            options: {
                splitKeysBy: '.',
                exclude: ['message', /label$/],
                deepExclude: true
            }
        }
    }
});

Merge multiple property files to one JSON file

If you want multiple property files to be merged to one JSON file, you can set the merge option to true. The destination should be a file in which the merged JSON output will be written. You can combine this option with the options mentioned above (the merge will be applied as last operation, so splitted keys will also be merged).

grunt.initConfig({
    propertiesToJSON: {
        main: {
            src: ['path/to/properties/files', 'another/path/to/properties/files'],
            dest: 'tmp.json',
            options: {
                merge: true
            }
        }
    }
});

License

This project is released under the MIT license.