jsonmap

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

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

Go to latest
Published: Mar 31, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

jsonmap.Ordered

GoDoc Travis-CI Go Report Card

Package jsonmap provides tools to serialize a map as JSON using a given order for keys.

Use the following type to wrap any map[string]interface{}:

type Ordered struct {
    Order []string // Order of keys
    Data map[string]interface{}
}

Documentation

Overview

Package jsonmap provides tools to serialize a map as JSON using a given order for keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ordered

type Ordered struct {
	Order []string // Order of keys
	Data  map[string]interface{}
}

Ordered wraps a map[string]interface{}.

func (Ordered) MarshalJSON

func (o Ordered) MarshalJSON() ([]byte, error)

MarshalJSON implements interface encoding/json.Marshaler. MarshalJSON returns o.Data serialized as JSON. The keys in o.Order are serialized first. If keys not in o.Order remain, they are sorted.

func (*Ordered) UnmarshalJSON

func (o *Ordered) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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