github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/types/jsonconcat/map.go (about) 1 package jsonconcat 2 3 import ( 4 "github.com/lmorg/murex/config" 5 "github.com/lmorg/murex/lang" 6 "github.com/lmorg/murex/lang/stdio" 7 "github.com/lmorg/murex/lang/types" 8 "github.com/lmorg/murex/utils/json" 9 ) 10 11 func readMap(read stdio.Io, _ *config.Config, callback func(*stdio.Map)) error { 12 // Create a marshaller function to pass to ArrayWithTypeTemplate 13 marshaller := func(v interface{}) ([]byte, error) { 14 return json.Marshal(v, read.IsTTY()) 15 } 16 17 return lang.MapTemplate(types.Json, marshaller, json.Unmarshal, read, callback) 18 }