Socket
Socket
Sign inDemoInstall

properties-to-json

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    properties-to-json

Convert a Java properties file to JSON (with JavaScript).


Version published
Weekly downloads
30K
increased by5.68%
Maintainers
1
Install size
21.8 kB
Created
Weekly downloads
 

Readme

Source

Convert Java .properties files to JSON (using JavaScript).

The function propertiesToJSON takes a string and returns a JavaScript object.

Read a local file in node:

const fs = require("fs");
const path = require("path");
const filePath = path.join(__dirname, "sample.properties");
const propertiesToJSON = require("properties-to-json");

fs.readFile(filePath, { encoding: "utf-8" }, (err, data) => {
    if (!err) {
        console.log(propertiesToJSON(data));
    }
});

Read a remote file in the browser:

const propertiesToJSON = require("properties-to-json");

const propsFile = new Request(
    "https://gitcdn.link/repo/ryanpcmcquen/propertiesToJSON/master/sample.properties"
);

const props = fetch(propsFile)
    .then((response) => {
        return response.text();
    })
    .then((text) => {
        const propsText = propertiesToJSON(text);
        console.log(propsText);
        return propsText;
    });

How do I get it?

  1. yarn add properties-to-json
  2. Profit.

Keywords

FAQs

Last updated on 27 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc