Skip to content

A Golang implementation of the Jackson-Smile data format

Notifications You must be signed in to change notification settings

zencoder/go-smile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

06ef4fe · Feb 21, 2022

History

12 Commits
Oct 5, 2020
Feb 21, 2022
Oct 9, 2020
Oct 9, 2020
Feb 21, 2022
Oct 5, 2020
Feb 21, 2022
Oct 5, 2020
Feb 21, 2022
Oct 5, 2020
Feb 21, 2022

Repository files navigation

go-smile :)

A Golang implementation of the Jackson-Smile binary JSON data format.

What's supported

  • Decoding is fully supported minus:

    • Big Decimals
  • Encoding is not yet supported

Developing

Build, format and run all tests with:

make

Tests

Test cases can be found under test/testdata. Each test case has a .smile and equivalent .json file.

Any new pairs of files added to this directory will be automatically included in the test suite.

Usage

package main

import (
	"fmt"
	"io/ioutil"
	"log"

	"github.com/zencoder/go-smile/smile"
)

func main() {
	var smileFile = "test/testdata/unicode.smile"

	b, err := ioutil.ReadFile(smileFile)
	if err != nil {
		log.Fatal("Error reading Smile file:", smileFile)
	}

	j, err := smile.DecodeToJSON(b)
	if err != nil {
		log.Fatal("Error decoding Smile file:", smileFile)
	}

	fmt.Println(j)
}
$ go run main.go 
{"child":"Niño","child-jp":"子供","chilllllllllllllllllllllllld":"Niñññññññññññññññññññññññño"}

The following convenience method is also provided for decoding to a Go representation of the JSON:

obj, err := smile.DecodeToObject(b)