Experimenting with different ways of processing JSON in Go
Go
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Godeps
.gitignore
README.md
compiled.txt
loose_struct.go
main.go
sample-battlesnake-move.json
sample-battlesnake-move.paw
strict_struct.go
wrapper.go

README.md

golang-json-experiment

This project tests various mechanisms for parsing JSON in Go. Commentary on each here: http://sean.lyn.ch/2015/02/parsing-json-in-go/

To run:

$ godep restore
$ go build
$ ./golang-json-experiment

Classes of mechanisms

  • strict_struct.go - Parsing JSON into predefined structures. This includes structure definitions generated by: gojson, json-to-go, jflect, and json-to-struct
  • loose_struct.go - Dealing with JSON that is parsed into the empty interface.
  • wrapper.go - Using empty interface wrapping packages to handle type conversion. This includes: typed, go-simplejson, and jason
  • TODO compiled.go - Using tools to pre-compile JSON parsers for performance reasons.

Sample data

Sample JSON used to test is included as raw JSON and Paw project.

At this time, only one sample JSON set is included: