Registering External JSON Library

Since v0.8 aah provides an option to register external/third party JSON library. By default aah framework uses Go built-in library.

This idea is from my one of the Go library resty. You can register standard JSON compatible library into aah; such as json-iterator, ffjson, etc.

Example of registering json-iterator library

import "github.com/json-iterator/go"

func init()  {
  aah.JSONMarshal = jsoniter.Marshal
	aah.JSONMarshalIndent = jsoniter.MarshalIndent
}

By default, jsoniter do not sort the map keys like standard library. If you want 100% compatibility, register as follows:

import "github.com/json-iterator/go"

func init() {
	jjson := jsoniter.ConfigCompatibleWithStandardLibrary
	aah.JSONMarshal = jjson.Marshal
	aah.JSONMarshalIndent = jjson.MarshalIndent
}

Example of registering ffjson library

import "github.com/pquerna/ffjson/ffjson"

func init() {
  aah.JSONMarshal = ffjson.Marshal
}