qjson

package module
v0.0.0-...-d179809 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 4 Imported by: 1

README

qjson

A json dialect that is very quick and easy to write by hand. It can be converted to plain json or used directly with the go library.

Documentation

Overview

Package flat flattens a nested Golang map into a one level deep map. Flat also supports unflatten, turn a one level map into nested one.

You can flatten a Go map

in = map[string]interface{}{
    "foo": map[string]interface{}{
        "bar": map[string]interface{}{
            "t": 123,
        },
        "k": 456,
    },
}

out, err := flat.Flatten(in, nil)
// out = map[string]interface{}{
//     "foo.bar.t": 123,
//     "foo.k": 456,
// }

and a reverse with unflatten

in = map[string]interface{}{
    "foo.bar.t": 123,
    "foo.k": 456,
}
out, err := flat.Unflatten(in, nil)
// out = map[string]interface{}{
//     "foo": map[string]interface{}{
//         "bar": map[string]interface{}{
//             "t": 123,
//         },
//         "k": 456,
//     },
// }

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unflatten

func Unflatten(flat interface{}, opts *Options) (nested interface{}, err error)

Unflatten the map, it returns a nested map of a map By default, the flatten has Delimiter = "."

func Unmarshal

func Unmarshal(data []byte) (interface{}, error)

Unmarshal unmarshals the qjson in data into v

Types

type Options

type Options struct {
	Delimiter string
	Safe      bool
	MaxDepth  int
}

Options the flatten options. By default: Demiliter = "."

Jump to

Keyboard shortcuts

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