murex Shell Docs

API Reference: lang.UnmarshalData()

Converts a murex data-type into structured memory



data, err := lang.UnmarshalData(p, dataType)


func exampleCommand(p *lang.Process) error {
    data := string `{ "foo": "hello foo", "bar": "hello bar" }`

    dataType := "json"

    v, err := lang.UnmarshalData(p, dataType)
    if err != nil {
        return err

    s := fmt.Sprint(v)
    _, err := p.Stdout.Write([]byte(s))
    return err


Go source file:

package lang

import (

// UnmarshalData is a global unmarshaller which should be called from within
// murex builtin commands (etc).
// See docs/apis/marshaldata.html for more details
func UnmarshalData(p *Process, dataType string) (v interface{}, err error) {
    // This is one of the very few maps in Murex which isn't hidden behind a sync
    // lock of one description or other. The rational is that even mutexes can
    // add a noticeable overhead on the performance of tight loops and I expect
    // this function to be called _a lot_ while also only needing to be written
    // to via code residing in within builtin types init() function (ie while
    // murex is effectively single threaded). So there shouldn't be any data-
    // races -- PROVIDING developers strictly follow the pattern of only writing
    // to this map within init() func's.
    if Unmarshallers[dataType] == nil {
        return nil, errors.New("I don't know how to unmarshal `" + dataType + "`.")

    v, err = Unmarshallers[dataType](p)
    if err != nil {
        return nil, errors.New("[" + dataType + " unmarshaller] " + err.Error())

    return v, nil


  1. *lang.Process: Process's runtime state. Typically expressed as the variable p
  2. string: murex data type

See Also

This site is rebuilt weekly, the content is automatically generated from murex's source code. Last built on Mon Aug 3 06:12:53 UTC 2020 against commit 2557f7c2557f7cc7535c452c21d89164bd38ed8996f02fd. Downloadable murex binaries are also built weekly. Current version is 0.52.2000 BETA which has been verified against tests.