
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
any-json can be used to convert (almost) anything to and from JSON.
npm install any-json -g
# Prints as JSON to standard out
any-json package.json5
# Writes the contents from `package.json` to `package.json5` as JSON5
any-json package.json package.json5
# Same as above (the `convert` command is default).
any-json convert package.json5
any-json convert package.json package.json5
# Prints an JSON array containing an item for every JSON file in directory
any-json combine *.json
# Combines A.json and B.json, writing the result to C.json
any-json combine A.json B.json --out C.json
# Create a csv from a collection of flat YAML files
any-json combine *.yaml --out=data.csv
# Creates a JSON file for each row in the CSV where the name is based on the `product_id` column
any-json split products.csv prod-{product_id}.json
When only JSON features are used, conversion should not result in any data loss when using these formats.
Some loss of information may occur. Improved parsers/serializers could provide better compatibility, but implementation is provided as-is. Known issues are listed below the format.
ini
library would need to quote strings in order be recognize numbers)These formats are conceptually different and only work on a limited basis. With effort, conventions could be established to provide a more complete transfer but there will be some impedance.
Tabular formats:
usage: any-json [command] FILE [options] [OUT_FILE]
any-json can be used to convert (almost) anything to JSON.
This version supports:
cson, csv, hjson, ini, json, json5, toml, yaml
This version has is beta support for:
xls, xlsx
The beta formats should work, but since they are new,
behavior may change in later releases in response to feedback
without requiring a major version update.
command:
convert convert between formats (default when none specified)
combine combine multiple documents
split spilts a document (containing an array) into multiple documents
options:
-?, --help Prints this help and exits.
--version Prints version information and exits.
--input-format=FORMAT Specifies the format of the input (assumed by file
extension when not provided).
--output-format=FORMAT Specifies the format of the output (default: json or
assumed by file extension when available).
combine (additional options):
--out=OUT_FILE The output file.
const anyjson = require('any-json')
const obj = await anyjson.decode(/* string to parse */, /* format (string) */)
const str = await anyjson.encode(/* object to encode */, /* desired format (string) */)
Contributions welcome! If any-json is not meeting your needs or your have an idea for an improvement, please open an issue or create a pull request.
For detailed release history, see Releases.
FAQs
Convert (almost) anything to JSON.
The npm package any-json receives a total of 14,424 weekly downloads. As such, any-json popularity was classified as popular.
We found that any-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.