

A json to yaml cli tool
source link: https://github.com/solderjs/json2yaml
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Unmaintained Mirror
Please go to the real repo at https://git.coolaj86.com/coolaj86/json2yaml.js
json2yaml
A command-line utility to convert JSON to YAML (meaning a .json
file to a .yml
file)
The purpose of this utility is to pretty-print JSON in the human-readable YAML object notation (ignore the misnomer, YAML is not a Markup Language at all).
Installation
npm install -g json2yaml
Note
: To use npm
and json2yaml
you must have installed NodeJS
.
Usage
Specify a file:
json2yaml ./example.json > ./example.yml yaml2json ./example.yml | json2yaml > ./example.yml
Or pipe from stdin:
curl -s http://foobar3000.com/echo/echo.json | json2yaml wget -qO- http://foobar3000.com/echo/echo.json | json2yaml
Or require:
(function () { "use strict"; var YAML = require('json2yaml') , ymlText ; ymlText = YAML.stringify({ "foo": "bar" , "baz": "corge" }); console.log(ymlText); }());
Example
So, for all the times you want to turn JSON int YAML (YML):
{ "foo": "bar" , "baz": [ "qux" , "quxx" ] , "corge": null , "grault": 1 , "garply": true , "waldo": "false" , "fred": "undefined" }
becomes
--- foo: "bar" baz: - "qux" - "quxx" corge: null grault: 1 garply: true waldo: "false" fred: "undefined"
Note : In fact, both of those Object Notations qualify as YAML because JSON technically is a proper subset of YAML. That is to say that all proper YAML parsers parse proper JSON.
YAML can use either whitespace and dashes or brackets and commas .
For human readability, the whitespace-based YAML is preferrable. For compression and computer readability, the JSON syntax of YAML is preferrable.
Alias
json2yaml
has the following aliases:
jsontoyaml json2yml jsontoyml
Recommend
-
140
World countries in JSON, CSV, XML and YAML. Countries data This repository contains a list of world countries, as defined by ISO Standard 3166-1, in JSON, CSV...
-
71
README.md Angular CLI Development tools and libraries specialized for Angular This is the home of the DevKit and the Angular CLI code. You can...
-
7
Parsing JSON at the CLI: A Practical Introduction to `jq` (and more!)Published December 21, 2020jq is a command line tool for parsing and modifying JSON. It is useful for extracting relevant bits of information from tool...
-
6
1. Introduction ChoETL is an open source ETL (extract, transform and load) fra...
-
6
现代配置指南——YAML 比 JSON 高级在哪?一直以来,前端工程中的配置大多都是 .js 文件或者 .json 文件,最常见的比如:package.jsonbabel...
-
7
How to Implement your Own Tool Using HCL (bc I Hate YAML)April 8th 2022 new story4The HCL c...
-
2
超轻量级 JSON / XML / YAML 的 正序列化 与 反序列化 的 门面框架,不依赖具体的 JSON 实现,让业务代码与 Jackson、Gson、Fastjson 等彻底 解耦,让你可以在需要的时候轻松切换项目底层...
-
8
JSON is not a YAML subsetJSON is not a YAML subsetPeople on the internet believe that JSON is a subset of YAML, and that it's safe to parse JSON using a YAML parser:
-
7
jq (JSON Query utility for Bash CLI scripts) Define JMESPATH syntax in...
-
7
用 jc 將常見的 CLI 指令輸出轉成 JSON 或是 YAML 看到「kellyjonbrazil/jc」這個專案,展試一...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK