Skip to content
Snippets Groups Projects
Select Git revision
  • dd8967a88c88bd37cbc1a99b52544b33de204fd1
  • master default protected
  • 1.31
  • 4.24.2
  • 4.24.1
  • 4.24.0
  • 4.23.6
  • 4.23.5
  • 4.23.4
  • 4.23.3
  • 4.23.2
  • 4.23.1
  • 4.23.0
  • 4.22.3
  • 4.22.2
  • 4.22.1
  • 4.22.0
  • 4.21.0
  • 4.20.1
  • 4.20.0
  • 4.19.0
  • 4.18.0
  • 4.17.0
23 results

tree-menu.mjs

Blame
  • json-map.go 620 B
    // Copyright 2023 schukai GmbH
    // SPDX-License-Identifier: AGPL-3.0
    
    package jobqueue
    
    import (
    	"database/sql/driver"
    	"encoding/json"
    	"errors"
    )
    
    type JSONMap map[string]interface{}
    
    func (m *JSONMap) Scan(value interface{}) error {
    	bytes, ok := value.([]byte)
    	if !ok {
    		return errors.New("Scan source is not []byte")
    	}
    
    	if err := json.Unmarshal(bytes, m); err != nil {
    		return err
    	}
    	return nil
    }
    
    func (m JSONMap) Value() (driver.Value, error) {
    	if m == nil {
    		// Return NULL if the map is nil
    		return nil, nil
    	}
    
    	bytes, err := json.Marshal(m)
    	if err != nil {
    		return nil, err
    	}
    	return bytes, nil
    }