jsontidier

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

This code was copied from https://gitlab.com/c0b/go-ordered-json/blob/master/ordered.go and then heavily adjusted

Copyright ??

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONTidier

type JSONTidier struct {
	// contains filtered or unexported fields
}

the JSONTidier type, has similar operations as the default map, but maintained the keys order of inserted; similar to map, all single key operations (Get/Set/Delete) runs at O(1).

func NewJSONTidier

func NewJSONTidier(np NewParams) *JSONTidier

Create a new JSONTidier

func (*JSONTidier) MarshalJSON

func (jt *JSONTidier) MarshalJSON() ([]byte, error)

this implements type json.Marshaler interface, so can be called in json.Marshal(om)

func (*JSONTidier) TidyBytes

func (jt *JSONTidier) TidyBytes(orig []byte) ([]byte, error)

func (*JSONTidier) TidyString

func (jt *JSONTidier) TidyString(orig string) (string, error)

func (*JSONTidier) UnmarshalJSON

func (jt *JSONTidier) UnmarshalJSON(data []byte) error

this implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, om)

type NewParams

type NewParams struct {
	Indent    *string
	KeyOrder  map[string][]string
	ArraySort []string
	Debug     bool
}

Jump to

Keyboard shortcuts

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