Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@mobile/hjson
Advanced tools
⚡ This is a repackaging of:
https://github.com/laktak/hjson-js
This project has been modified from the original to be smaller for use with mobile frameworks
Hjson, the Human JSON. A configuration file format for humans. Relaxed syntax, fewer mistakes, more comments.
{
# specify rate in requests/second (because comments are helpful!)
rate: 1000
// prefer c-style comments?
/* feeling old fashioned? */
# did you notice that rate doesn't need quotes?
hey: look ma, no quotes for strings either!
# best of all
notice: []
anything: ?
# yes, commas are optional!
}
The JavaScript implementation of Hjson is based on JSON-js. For other platforms see hjson.org.
npm install hjson
var Hjson = require('hjson');
var obj = Hjson.parse(hjsonText);
var text2 = Hjson.stringify(obj);
To keep comments intact see API.
Install with npm install hjson -g
.
usage: hjson [OPTIONS] [INPUT]
hjson can be used to convert JSON from/to Hjson.
hjson will read the given JSON/Hjson input file or read from stdin.
- default: will output as Hjson.
- with -sl: will output the opening brace on the same line.
- with -root: will output braces for the root object.
- with -quote: will quote all strings.
- with -j or -json: will output as formatted JSON.
- with -c or -json=compact: will output as JSON.
Sample:
hjson test.json > test.hjson
to convert to Hjsonhjson -j test.hjson > test.json
to convert to JSONThe API is the same for the browser and node.js version.
This method parses JSON or Hjson text to produce an object or array.
This method produces Hjson text from a JavaScript value.
Gets or sets the stringify EOL sequence ('\n' or '\r\n'). When running with node.js this defaults to os.EOL.
This is a shortcut to roundtrip your comments when reading and updating a config file. It is the same as specifying the keepWsc option for the parse and stringify functions.
Require a config file directly.
require("hjson/lib/require-config");
var cfg=require("./config.hjson");
You can modify a Hjson file and keep the whitespace & comments intact (round trip). This is useful if an app updates its config file.
// parse, keep whitespace and comments
// (they are stored in a non enumerable __WSC__ member)
var data = Hjson.rt.parse(text);
// modify like you normally would
data.foo = "text";
// you can also edit comments by accessing __WSC__
var wsc = data.__WSC__;
// __WSC__ for objects contains { c: {}, o: [] }
// - c with the actual comment and
// - o (array) with the order of the members
wsc.c.hugo = "just another test";
wsc.o.splice(2, 0, "hugo");
data.hugo = "value";
data.arrayWithComments = [ "a" ];
// __WSC__ for arrays is just an array with the
// comments ([0] for the space before the elements)
data.arrayWithComments.__WSC__ = [ "before a", "after a" ];
// convert back to Hjson
console.log(Hjson.rt.stringify(data));
FAQs
Repackaged version of Hjson, the Human JSON, for mobile
The npm package @mobile/hjson receives a total of 1 weekly downloads. As such, @mobile/hjson popularity was classified as not popular.
We found that @mobile/hjson 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.