code: func ConvertJSONToInt(sc *stmtctx.StatementContext, j json.BinaryJSON, unsigned bool) (int64, error) {
  	switch j.TypeCode {
  	case json.TypeCodeObject, json.TypeCodeArray:
  		return 0, nil
  	case json.TypeCodeLiteral:
  		switch j.Value[0] {
  		case json.LiteralNil, json.LiteralFalse:
  			return 0, nil
  		default:
  			return 1, nil
  		}
  	case json.TypeCodeInt64, json.TypeCodeUint64:
  		return j.GetInt64(), nil
  	case json.TypeCodeFloat64:
  		f := j.GetFloat64()
  		if !unsigned {
  			lBound := IntergerSignedLowerBound(mysql.TypeLonglong)
  			uBound := IntergerSignedUpperBound(mysql.TypeLonglong)
  			return ConvertFloatToInt(f, lBound, uBound, mysql.TypeDouble)
  		}
  		bound := IntergerUnsignedUpperBound(mysql.TypeLonglong)
  		u, err := ConvertFloatToUint(sc, f, bound, mysql.TypeDouble)
  		return int64(u), errors.Trace(err)
  	case json.TypeCodeString:
  		str := string(hack.String(j.GetString()))
  		return StrToInt(sc, str)
  	}
  	return 0, errors.New("Unknown type code in JSON")
  }
docs: // ConvertJSONToInt casts JSON into int64.