github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/types/json/json.go (about) 1 package json 2 3 import ( 4 "github.com/lmorg/murex/lang" 5 "github.com/lmorg/murex/lang/stdio" 6 "github.com/lmorg/murex/lang/types" 7 ) 8 9 func init() { 10 // Register data type 11 lang.Marshallers[types.Json] = marshal 12 lang.Unmarshallers[types.Json] = unmarshal 13 lang.ReadIndexes[types.Json] = index 14 lang.ReadNotIndexes[types.Json] = index 15 16 stdio.RegisterReadArray(types.Json, readArray) 17 stdio.RegisterReadArrayWithType(types.Json, readArrayWithType) 18 stdio.RegisterReadMap(types.Json, readMap) 19 stdio.RegisterWriteArray(types.Json, newArrayWriter) 20 21 lang.SetMime(types.Json, 22 "application/json", // this is preferred, but we include the others incase a website sends a non-standard MIME time 23 "application/x-json", 24 "text/json", 25 "text/x-json", 26 ) 27 lang.SetFileExtensions(types.Json, "json", "tfstate") 28 }