
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
json-to-properties
Advanced tools
A standalone utility to transform language files in JSON format into .properties files, and languages files in .properties format into JSON format.
A util to convert files having a .json
format into .properties
format, and vice versa.
npm install json-to-properties -g
Running json-to-properties
will convert any .json
files that are found in the current directory, into to .properties
files.
Example
{
"KEY1": {
"KEY2": "Hello"
},
"KEY3":"World"
}
result in a file containing
KEY1.KEY2=Hello
KEY3=World
Various options are supported, including
Running the util with -c expects a config file in .json
format containing two attributes: src
and dist
, where
src
points to the directory containing the files to process anddist
points to the directory where the output files will be writtenExample config.json
{
src: "c:\json\myfiles",
dist: "c:\properties\myconvertedfiles"
}
and run with
json-to-properties -c config.json
Performs the reversal process, converting .properties
files into .json
files.
Example
KEY1.KEY2=Hello
KEY3=World
result into a file containing
{
"KEY1": {
"KEY2": "Hello"
},
"KEY3":"World"
}
Accepts a number value identifying the number of spaces used within the output .json file. This is used in relation with -r, --reverse
Run using
json-to-properties -r -s 4
will use 4 spaces for each indented hierarchy.
Running the util with the -m, --merge
option bundles the generated .properties
files into one file of a given name, or bundle.properties
if none is specified. The content of the bundled file are prefixed with the name of the original file.
json-to-properties -m
bundles the content in a file named bundle.properties
json-to-properties -m mynewbundle.properties
bundles the content in a file named mynewbundle.properties
Having two files en.json
and it.json
both containing the json content below
{
"KEY1" : "Hello Sir",
"KEY2" : "How is your day?"
}
will result in a bundle file bundle.properties
having the below content.
EN.KEY1=Hello Sir
EN.KEY2=How is your day?
IT.KEY1=Hello Sir
IT.KEY2=How is your day?
Note that the standard behavior is preserved, thus two properties files en.properties
and it.properties
are also created.
The merge process can also be combined with the -r, -reverse
flag, where the specified file (or bundle.properties
if none is specified) is expanded into separate json files whose name is equivalent to the first part of a key.
json-to-properties -r -m
or json-to-properties -rm
Having a bundle file bundle.properties
with the below content
EN.KEY1=Hello Sir
EN.KEY2=How is your day?
IT.KEY1=Salve signore
IT.KEY2=Com'è la tua giornata?
will result in two files, en_rm.json
and it_rm.json
, having the below content respectively.
{
"KEY1": "Hello Sir",
"KEY2": "How is your day?"
}
and
{
"KEY1": "Salve signore",
"KEY2": "Com'è la tua giornata?"
}
Note that the generated json files are suffixed with _rm not to override other .json files having the same name (in this case, en.json
and it.json
) that could be a result of the standard behavior of the reverse process.
The sample
folder contains both .json and .properties files to download and test on.
FAQs
A standalone utility to transform language files in JSON format into .properties files, and languages files in .properties format into JSON format.
The npm package json-to-properties receives a total of 514 weekly downloads. As such, json-to-properties popularity was classified as not popular.
We found that json-to-properties demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.