properties-to-object
v1.0.2
Published
Parse property file structures into object structures
Downloads
7
Readme
Parse Properties to Objects
Simple parser to handle property file based key names and parse them into objects. The key name separations with points is transferred into an object structure.
npm install properties-to-object --save
const parser = require("properties-to-object");
var config = parser({
"some.property": "value",
"other": "123"
});
console.log(config.some.property);
Use with Spring Cloud Config
This node module is intended to be used in combination with results from spring cloud configuration servers as provided by using the module cloud-config-client.
npm install cloud-config-client properties-to-object --save
const client = require("cloud-config-client")
const parser = require("properties-to-object")
client.load({
application: "invoices"
}).then((config) => {
// Rebuild config from server into map with key value pairs
var result = {}
config.forEach((k,v) => {
result[k] = v
}
// Use parser to create configuration object
var configuration = parser(result)
});