diff --git a/const.go b/const.go index 83e9e7c..7a7fed9 100644 --- a/const.go +++ b/const.go @@ -5,10 +5,10 @@ package fj // If set to false, modifiers will be applied as expected. var DisableModifiers = false -// modifiers is a map that associates a string key (the modifier type) with a function that +// jsonTransformers is a map that associates a string key (the modifier type) with a function that // takes two string arguments (`json` and `arg`), and returns a modified string. The map is used -// to apply various transformations to JSON data based on the specified modifiers. -var modifiers map[string]func(json, arg string) string +// to apply various transformations to JSON data based on the specified jsonTransformers. +var jsonTransformers map[string]func(json, arg string) string // hexDigits is an array of bytes representing the hexadecimal digits used in JSON encoding. // It contains the characters '0' to '9' and 'a' to 'f', which are used for encoding hexadecimal numbers. diff --git a/fj.go b/fj.go index 6cf0261..c4c5928 100644 --- a/fj.go +++ b/fj.go @@ -544,7 +544,7 @@ func IsValidJSONBytes(json []byte) bool { // - Once registered, the modifier can be used in fj queries to transform the JSON data // according to the logic defined in the `fn` function. func AddModifier(name string, fn func(json, arg string) string) { - modifiers[name] = fn + jsonTransformers[name] = fn } // IsModifierRegistered checks whether a specified modifier has been registered in the fj system. @@ -577,10 +577,10 @@ func IsModifierRegistered(name string) bool { if unify4g.IsEmpty(name) { return false } - if len(modifiers) == 0 { + if len(jsonTransformers) == 0 { return false } - _, ok := modifiers[name] + _, ok := jsonTransformers[name] return ok } @@ -1621,7 +1621,7 @@ func (t Type) String() string { } func init() { - modifiers = map[string]func(json, arg string) string{ + jsonTransformers = map[string]func(json, arg string) string{ "pretty": applyPretty, "ugly": modUgly, "reverse": modReverse, diff --git a/h.go b/h.go index 9d4e4d7..cc2e675 100644 --- a/h.go +++ b/h.go @@ -1929,7 +1929,7 @@ func isModifierOrJSONStart(s string) bool { break } } - _, ok := modifiers[s[1:i]] + _, ok := jsonTransformers[s[1:i]] return ok } return c == '[' || c == '{' @@ -3518,7 +3518,7 @@ func adjustModifier(json, path string) (pathYield, result string, ok bool) { } } // check if the modifier exists in the modifiers map and apply it if found. - if fn, ok := modifiers[name]; ok { + if fn, ok := jsonTransformers[name]; ok { var args string if hasArgs { // if arguments are found, parse and handle them. var parsedArgs bool