Have got text transformations working
This commit is contained in:
parent
9f2fa96b92
commit
41daf7cfc9
14 changed files with 178 additions and 17 deletions
22
textfilters.go
Normal file
22
textfilters.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type TextFilter func(input string) (output string, err error)
|
||||
|
||||
var TextFilters = map[string]TextFilter{
|
||||
"unquote": func(input string) (output string, err error) {
|
||||
return strconv.Unquote(input)
|
||||
},
|
||||
"format-json": func(input string) (output string, err error) {
|
||||
var dst bytes.Buffer
|
||||
if err := json.Indent(&dst, []byte(input), "", " "); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return dst.String(), nil
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue