package productsRepo import ( "encoding/json" "fmt" "git.ma-al.com/goc_daniel/b2b/app/db" ) type UIProductsRepo interface { GetJSON(p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*json.RawMessage, error) } type ProductsRepo struct{} func New() UIProductsRepo { return &ProductsRepo{} } func (repo *ProductsRepo) GetJSON(p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity int) (*json.RawMessage, error) { var productStr string // ← Scan as string first err := db.DB.Raw(`CALL get_full_product(?,?,?,?,?,?)`, p_id_product, p_id_shop, p_id_lang, p_id_customer, b2b_id_country, p_quantity). Scan(&productStr). Error if err != nil { return nil, err } // Optional: validate it's valid JSON if !json.Valid([]byte(productStr)) { return nil, fmt.Errorf("invalid json returned from stored procedure") } raw := json.RawMessage(productStr) return &raw, nil }