yaml2json

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2023 License: MIT Imports: 6 Imported by: 5

README

go-yaml2json

Tests GoDoc Go Report Card

Get it on Codeberg

golang lib to convert yaml into json

go get codeberg.org/6543/go-yaml2json
yaml2json.Convert(data []byte) ([]byte, error)
yaml2json.StreamConvert(r io.Reader, w io.Writer) error

Example

Go Playground

yaml:

- name: Jack
  job: Butcher
- name: Jill
  job: Cook
  obj:
    empty: false
    data: |
      some data 123
      with new line      

will become json:

[
  {
    "job": "Butcher",
    "name": "Jack"
  },
  {
    "job": "Cook",
    "name": "Jill",
    "obj": {
      "data": "some data 123\nwith new line\n",
      "empty": false
    }
  }
]

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBrokenMappingNode = errors.New("broken mapping node")
	ErrUnsupportedNode   = errors.New("unsupported yaml node")
	ErrMaxDepth          = errors.New("max depth reached")
)

Functions

func Convert added in v0.2.0

func Convert(data []byte) ([]byte, error)

Convert YAML bytes to JSON bytes

func ConvertNode added in v0.3.0

func ConvertNode(m *yaml.Node) ([]byte, error)

ConvertNode convert a gopkg.in/yaml.v3 Node to JSON bytes

func StreamConvert added in v0.2.0

func StreamConvert(r io.Reader, w io.Writer) error

StreamConvert convert YAML byte stream to JSON byte stream

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL