All Projects → any-json → Any Json

any-json / Any Json

Licence: mit
Convert (almost) anything to JSON

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Any Json

Dataset Serialize
JSON to DataSet and DataSet to JSON converter for Delphi and Lazarus (FPC)
Stars: ✭ 213 (+66.41%)
Mutual labels:  json, converter
Remarshal
Convert between CBOR, JSON, MessagePack, TOML, and YAML
Stars: ✭ 421 (+228.91%)
Mutual labels:  json, converter
Retrofit Logansquare
A Converter implementation using LoganSquare JSON serialization for Retrofit 2.
Stars: ✭ 224 (+75%)
Mutual labels:  json, converter
Node Js2xmlparser
Popular Node.js module for parsing JavaScript objects into XML
Stars: ✭ 171 (+33.59%)
Mutual labels:  json, converter
Inspec tools
A command-line and ruby API of utilities, converters and tools for creating, converting and processing security baseline formats, results and data
Stars: ✭ 65 (-49.22%)
Mutual labels:  json, converter
Swagger Toolbox
💡 Swagger schema model (in yaml, json) generator from json data
Stars: ✭ 194 (+51.56%)
Mutual labels:  json, converter
Jet
CLI to transform between JSON, EDN and Transit, powered with a minimal query language.
Stars: ✭ 331 (+158.59%)
Mutual labels:  json, converter
Sqawk
Like Awk but with SQL and table joins
Stars: ✭ 263 (+105.47%)
Mutual labels:  json, converter
I18n Generator
i18n json files generator for node, web browser and command line
Stars: ✭ 60 (-53.12%)
Mutual labels:  json, converter
Jsontocodable
A generating tool from Raw JSON to Codable (Swift4) text written in Swift4.
Stars: ✭ 33 (-74.22%)
Mutual labels:  json, converter
Goxml2json
XML to JSON converter written in Go (no schema, no structs)
Stars: ✭ 170 (+32.81%)
Mutual labels:  json, converter
Perun
A command-line validation tool for AWS Cloud Formation that allows to conquer the cloud faster!
Stars: ✭ 82 (-35.94%)
Mutual labels:  json, converter
Gelatin
Transform text files to XML, JSON, or YAML
Stars: ✭ 150 (+17.19%)
Mutual labels:  json, converter
Jsonsubtypes
Discriminated Json Subtypes Converter implementation for .NET
Stars: ✭ 201 (+57.03%)
Mutual labels:  json, converter
Sqlitebiter
A CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.
Stars: ✭ 601 (+369.53%)
Mutual labels:  json, converter
Json Ditto
Declarative JSON-to-JSON mapper .. shape-shift JSON files with Ditto 👻
Stars: ✭ 66 (-48.44%)
Mutual labels:  json, converter
Json Node Normalizer
'json-node-normalizer' - NodeJS module that normalize json data types from json schema specifications.
Stars: ✭ 105 (-17.97%)
Mutual labels:  json, converter
Coc Json
Json language extension for coc.nvim
Stars: ✭ 123 (-3.91%)
Mutual labels:  json
Burner.kiwi
No bullshit temporary mail service written in Go
Stars: ✭ 126 (-1.56%)
Mutual labels:  json
Fhir Converter
Conversion utility to translate legacy data formats into FHIR
Stars: ✭ 123 (-3.91%)
Mutual labels:  converter

any-json

any-json can be used to convert (almost) anything to and from JSON.

NPM version

Install from npm

npm install any-json -g

Examples

convert

# 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

combine

# 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

split

# 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

Formats and Data Safety

Safe

When only JSON features are used, conversion should not result in any data loss when using these formats.

  • cson
  • hjson
  • json
  • json5
  • yaml

Problematic

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
    • All numbers are converted to strings (the ini library would need to quote strings in order be recognize numbers)
    • In the unlikely case an object was not an array but has only has sequential, numeric members starting at zero it will be decoded as an array.
  • toml
    • Top-level array and date objects are not supported
      • It would be non-standard, but this could be worked around by wrapping the content in an object (then discarding the object when decoding).
  • xml

Limited

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:

  • csv
  • xls
  • xlsx

Usage

Command Line

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.

API

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) */)

Contributing

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.

History

For detailed release history, see Releases.

  • v3 Re-written to be Promise-based and bi-directional (serialization capabilities as well as parsing).
  • v2 removed the experimental/unreliable format detection.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].