GithubHelp home page GithubHelp logo

gojsontoyaml's Introduction

gojsontoyaml

This is a small tool written in go to convert json to yaml reading from STDIN and writing to STDOUT. The heavy lifting is actually done by ghodss/yaml and gopkg.in/yaml.v2.

Install

To install simply

go install github.com/brancz/gojsontoyaml@latest

Usage

Simply pipe a json string into gojsontoyaml and it will print the converted yaml string to STDOUT.

$ echo '{"test":"test string with\\nmultiple lines"}' | gojsontoyaml
test: |-
  test string with
  multiple lines

Motivation

You may ask yourself why this was developed. The answer is simple, when I wrote this there was no simple to use binary for this purpose that supported yaml multiline strings. All alternatives out there that I tried kept line breaks in the string rather than making use of the yaml multiline strings.

gojsontoyaml's People

Contributors

bearice avatar brancz avatar dgrisonnet avatar klavsklavsen avatar kouk avatar maikelvl avatar metalmatze avatar underrun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gojsontoyaml's Issues

Long line wrapping jitter across "versions"

i've used different commits of gojsontoyaml over the years. the behavior of wrapping long lines changes depending on when had go geted as follows:

  • Pre May 2020: long lines wrap
  • Between May 2020 and Dec 2020: long lines do not wrap
  • After Dec 2020: long lines wrap

... and to top that off, at some point in the future with yaml.v3 the default will again be the long lines will not wrap...

This is because of this fun: go-yaml/yaml#670 combined with the timing of updating the go mod for yaml.v2 in this repo (2.2.8 pre may, 2.3.0 may, 2.4.0 dec)

I'd love it if the line wrapping could shift back to the future of not doing it.

install method no longer works with Go 1.17+

$  go get github.com/brancz/gojsontoyaml
go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

Is not working in Fedora

$ go install github.com/brancz/gojsontoyaml@latest

$ echo '{"test":"test string with\nmultiple lines"}' | gojsontoyaml
bash: gojsontoyaml: command not found...

$ uname -a
Linux fedora 5.16.16-200.fc35.x86_64 #1 SMP PREEMPT Sat Mar 19 13:52:41 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Space at end of line will not result in yaml multiline string

If we modify the example on the home page

echo '{"test":"test string with\nmultiple lines"}' | gojsontoyaml
test: |-
  test string with
  multiple lines

To include a space char after test string with then the output is not a multiline yaml string as expected.

echo '{"test":"test string with \nmultiple lines"}' | gojsontoyaml
test: "test string with \nmultiple lines"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.