modutils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendCallStack

func AppendCallStack(entry *zerolog.Event, runtime *goja.Runtime) *zerolog.Event

func ToYAMLStr

func ToYAMLStr(in interface{}) (string, error)

func YamlToJSON

func YamlToJSON(input string) ([]byte, error)

process all documents from input and return them encode as json

if only one document exists, then it returns a single object, otherwise it returns a json.

Keys that are not strings will be converted to strings, except null and binary which will not be processed.

Empty documents are added ass empty json documents, eg.:

example.yaml: name: "first" --- name: "second" --- --- 10: "int key" 10.1: "float key"

Will be encoded as example.json: [

{ "name": "fist"},
{ "name": "second"},
{},
{ "10": "int key", "10.1": "float key"}

]

Non-string keys are encoded using fmt.Sprintf("%v", nonStringValue), except for binary/null keys which are not supported at all!

Binary data is encoded to base64

This whole code is probably full of bugs that might cause some unexpected behaviour, but for that matter, using non string keys in Yaml comes with its own set of challenges...

So I hope people won't be too mad about some inconsistencies here... (famous last words rigth?!)

Types

This section is empty.

Jump to

Keyboard shortcuts

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