All Projects → jeremyfa → Yaml.js

jeremyfa / Yaml.js

Licence: mit
Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects

Projects that are alternatives of or similar to Yaml.js

Json Schema Validator
A fast Java JSON schema validator that supports draft V4, V6, V7 and V2019-09
Stars: ✭ 292 (-63.95%)
Mutual labels:  json, yaml
I18n Manager
Translation management app
Stars: ✭ 373 (-53.95%)
Mutual labels:  json, yaml
Envfile
EnvFile 3.0 is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.
Stars: ✭ 293 (-63.83%)
Mutual labels:  json, yaml
Quicklib
Quick development library (AutoMapper, LinQ, IOC Dependency Injection, MemoryCache, Scheduled tasks, Config, Serializers, etc) with crossplatform support for Delphi/Firemonkey (Windows,Linux,OSX/IOS/Android) and freepascal (Windows/Linux).
Stars: ✭ 274 (-66.17%)
Mutual labels:  json, yaml
Panini
A super simple flat file generator.
Stars: ✭ 562 (-30.62%)
Mutual labels:  json, yaml
Korio
Korio: Kotlin cORoutines I/O : Virtual File System + Async/Sync Streams + Async TCP Client/Server + WebSockets for Multiplatform Kotlin 1.3
Stars: ✭ 282 (-65.19%)
Mutual labels:  json, yaml
Jk
Configuration as Code with ECMAScript
Stars: ✭ 322 (-60.25%)
Mutual labels:  json, yaml
Config
JSON or YAML configuration wrapper with convenient access methods.
Stars: ✭ 237 (-70.74%)
Mutual labels:  json, yaml
Remarshal
Convert between CBOR, JSON, MessagePack, TOML, and YAML
Stars: ✭ 421 (-48.02%)
Mutual labels:  json, yaml
Packagedev
Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
Stars: ✭ 378 (-53.33%)
Mutual labels:  json, yaml
Cli
A simple, fast, and fun package for building command line apps in Go
Stars: ✭ 16,995 (+1998.15%)
Mutual labels:  json, yaml
Structured Text Tools
A list of command line tools for manipulating structured text data
Stars: ✭ 6,180 (+662.96%)
Mutual labels:  json, yaml
Vscode Data Preview
Data Preview 🈸 extension for importing 📤 viewing 🔎 slicing 🔪 dicing 🎲 charting 📊 & exporting 📥 large JSON array/config, YAML, Apache Arrow, Avro, Parquet & Excel data files
Stars: ✭ 245 (-69.75%)
Mutual labels:  json, yaml
Dyff
/ˈdʏf/ - diff tool for YAML files, and sometimes JSON
Stars: ✭ 277 (-65.8%)
Mutual labels:  json, yaml
Thorsserializer
C++ Serialization library for JSON
Stars: ✭ 241 (-70.25%)
Mutual labels:  json, yaml
Tmuxp
💻 tmux session manager. built on libtmux
Stars: ✭ 3,269 (+303.58%)
Mutual labels:  json, yaml
Config
📝 Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Stars: ✭ 225 (-72.22%)
Mutual labels:  json, yaml
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: ✭ 225 (-72.22%)
Mutual labels:  json, yaml
Choetl
ETL Framework for .NET / c# (Parser / Writer for CSV, Flat, Xml, JSON, Key-Value, Parquet, Yaml, Avro formatted files)
Stars: ✭ 372 (-54.07%)
Mutual labels:  json, yaml
Countries
World countries in JSON, CSV, XML and Yaml. Any help is welcome!
Stars: ✭ 5,379 (+564.07%)
Mutual labels:  json, yaml

Build status

⚠️ Development of this library has slowed-down

I am still using yaml.js in production for some projects, it works fine in all the situations I needed it. That said, I am not actively working with raw javascript environments (mostly using haxe now, if you are curious), thus I don't have much bandwidth to actively provide support to the posted issues asking for new features or bugfixes that don't affect my own use cases of the library. If this situation is an issue for you, I suggest you use js-yaml which is a great and pretty feature-complete yaml parser and dumper for javascript. Pull Requests are still welcome, as long as they don't break the current set of unit tests!

Thanks 🙏

yaml.js

Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.

Mainly inspired from Symfony Yaml Component.

How to use

Import yaml.js in your html page:

<script type="text/javascript" src="yaml.js"></script>

Parse yaml string:

nativeObject = YAML.parse(yamlString);

Dump native object into yaml string:

yamlString = YAML.stringify(nativeObject[, inline /* @integer depth to start using inline notation at */[, spaces /* @integer number of spaces to use for indentation */] ]);

Load yaml file:

nativeObject = YAML.load('file.yml');

Load yaml file:

YAML.load('file.yml', function(result)
{
    nativeObject = result;
});

Use with node.js

Install module:

npm install yamljs

Use it:

YAML = require('yamljs');

// parse YAML string
nativeObject = YAML.parse(yamlString);

// Generate YAML
yamlString = YAML.stringify(nativeObject, 4);

// Load yaml file using YAML.load
nativeObject = YAML.load('myfile.yml');

Command line tools

You can enable the command line tools by installing yamljs as a global module:

npm install -g yamljs

Then, two cli commands should become available: yaml2json and json2yaml. They let you convert YAML to JSON and JSON to YAML very easily.

yaml2json

usage: yaml2json [-h] [-v] [-p] [-i INDENTATION] [-s] [-r] [-w] input

Positional arguments:
  input                 YAML file or directory containing YAML files.

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  -p, --pretty          Output pretty (indented) JSON.
  -i INDENTATION, --indentation INDENTATION
                        Number of space characters used to indent code (use 
                        with --pretty, default: 2).
  -s, --save            Save output inside JSON file(s) with the same name.
  -r, --recursive       If the input is a directory, also find YAML files in 
                        sub-directories recursively.
  -w, --watch           Watch for changes.

json2yaml

usage: json2yaml [-h] [-v] [-d DEPTH] [-i INDENTATION] [-s] [-r] [-w] input

Positional arguments:
  input                 JSON file or directory containing JSON files.

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  -d DEPTH, --depth DEPTH
                        Set minimum level of depth before generating inline 
                        YAML (default: 2).
  -i INDENTATION, --indentation INDENTATION
                        Number of space characters used to indent code 
                        (default: 2).
  -s, --save            Save output inside YML file(s) with the same name.
  -r, --recursive       If the input is a directory, also find JSON files in 
                        sub-directories recursively.
  -w, --watch           Watch for changes.

examples

# Convert YAML to JSON and output resulting JSON on the console
yaml2json myfile.yml

# Store output inside a JSON file
yaml2json myfile.yml > output.json

# Output "pretty" (indented) JSON
yaml2json myfile.yml --pretty

# Save the output inside a file called myfile.json
yaml2json myfile.yml --pretty --save

# Watch a full directory and convert any YAML file into its JSON equivalent
yaml2json mydirectory --pretty --save --recursive

# Convert JSON to YAML and store output inside a YAML file
json2yaml myfile.json > output.yml

# Output YAML that will be inlined only after 8 levels of indentation
json2yaml myfile.json --depth 8

# Save the output inside a file called myfile.json with 4 spaces for each indentation
json2yaml myfile.json --indentation 4

# Watch a full directory and convert any JSON file into its YAML equivalent
json2yaml mydirectory --pretty --save --recursive

Credits / Thanks

  • Symfony Yaml Component which was the reference implementation initially.
  • minj who did fix various bugs and ported a first batch of unit tests in an earlier version of yamljs.
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].