Awesome Go

mapslice-json

CategoryJSON
SubcategoryJSON
Stars0

Go MapSlice for ordered marshal/ unmarshal of maps in JSON

About mapslice-json

GoDoc Go Report Card License Coverage Status Build Status

mapslice-json

Go MapSlice for ordered marshal/ unmarshal of maps in JSON

Example

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/ake-persson/mapslice-json"
)

func main() {
	ms := mapslice.MapSlice{
		mapslice.MapItem{Key: "abc", Value: 123},
		mapslice.MapItem{Key: "def", Value: 456},
		mapslice.MapItem{Key: "ghi", Value: 789},
	}

	b, err := json.Marshal(ms)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(b))

	ms = mapslice.MapSlice{}
	if err := json.Unmarshal(b, &ms); err != nil {
		log.Fatal(err)
	}

	fmt.Println(ms)
}

Frequently Asked Questions

What is mapslice-json?

mapslice-json is a JSON library for the Go programming language. Go MapSlice for ordered marshal/ unmarshal of maps in JSON

How do I install mapslice-json?

Install mapslice-json with the Go module system using `go get mickep76/mapslice-json`. Check the repository for the current installation instructions.

What category does mapslice-json belong to?

mapslice-json is listed under JSON, specifically JSON.

← Back to JSON