func (t jsonType) Type() query.Type {
	return sqltypes.TypeJSON
}
Type implements Type interface.
package sql
import (
	"encoding/json"
	"github.com/dolthub/vitess/go/sqltypes"
	"github.com/dolthub/vitess/go/vt/proto/query"
	"gopkg.in/src-d/go-errors.v1"
)
var ErrConvertingToJSON = errors.NewKind("value %v is not valid JSON")
var JSON JsonType = jsonType{}
type JsonType interface {
	Type
}
type jsonType struct{}
func (t jsonType) Compare(a interface{}, b interface{}) (int, error) {
	var err error
	if a, err = t.Convert(a); err != nil {
		return 0, err
	}
	if b, err = t.Convert(b); err != nil {
		return 0, err
	}
	return a.(JSONValue).Compare(NewEmptyContext(), b.(JSONValue))
}
func (t jsonType) Convert(v interface{}) (doc interface{}, err error) {
	switch v := v.(type) {
	case JSONValue:
		return v, nil
	case []byte:
		err = json.Unmarshal(v, &doc)
	case string:
		err = json.Unmarshal([]byte(v), &doc)
	default:
		if _, err = json.Marshal(v); err == nil {
			return JSONDocument{Val: v}, nil
		}
	}
	if err != nil {
		return nil, err
	}
	return JSONDocument{Val: doc}, nil
}
func (t jsonType) Promote() Type {
	return t
}
func (t jsonType) SQL(v interface{}) (sqltypes.Value, error) {
	if v == nil {
		return sqltypes.NULL, nil
	}
	js, ok := v.(JSONValue)
	if !ok {
		return sqltypes.NULL, nil
	}
	s, err := js.ToString(NewEmptyContext())
	if err != nil {
		return sqltypes.NULL, err
	}
	return sqltypes.MakeTrusted(sqltypes.TypeJSON, []byte(s)), nil
}
func (t jsonType) String() string {
	return "JSON"
}