code: func (d *Datum) ToMysqlJSON() (j json.BinaryJSON, err error) {
  	var in interface{}
  	switch d.Kind() {
  	case KindMysqlJSON:
  		j = d.GetMysqlJSON()
  		return
  	case KindInt64:
  		in = d.GetInt64()
  	case KindUint64:
  		in = d.GetUint64()
  	case KindFloat32, KindFloat64:
  		in = d.GetFloat64()
  	case KindMysqlDecimal:
  		in, err = d.GetMysqlDecimal().ToFloat64()
  	case KindString, KindBytes:
  		in = d.GetString()
  	case KindBinaryLiteral, KindMysqlBit:
  		in = d.GetBinaryLiteral().ToString()
  	case KindNull:
  		in = nil
  	default:
  		in, err = d.ToString()
  	}
  	if err != nil {
  		err = errors.Trace(err)
  		return
  	}
  	j = json.CreateBinary(in)
  	return
  }
docs: // ToMysqlJSON is similar to convertToMysqlJSON, except the
  // latter parses from string, but the former uses it as primitive.