execStatic parses the path to find a static value. The input expects that the path already starts with a '!'
(json, path string)
| 2816 | // execStatic parses the path to find a static value. |
| 2817 | // The input expects that the path already starts with a '!' |
| 2818 | func execStatic(json, path string) (pathOut, res string, ok bool) { |
| 2819 | name := path[1:] |
| 2820 | if len(name) > 0 { |
| 2821 | switch name[0] { |
| 2822 | case '{', '[', '"', '+', '-', '0', '1', '2', '3', '4', '5', '6', '7', |
| 2823 | '8', '9': |
| 2824 | _, res = parseSquash(name, 0) |
| 2825 | pathOut = name[len(res):] |
| 2826 | return pathOut, res, true |
| 2827 | } |
| 2828 | } |
| 2829 | for i := 1; i < len(path); i++ { |
| 2830 | if path[i] == '|' { |
| 2831 | pathOut = path[i:] |
| 2832 | name = path[1:i] |
| 2833 | break |
| 2834 | } |
| 2835 | if path[i] == '.' { |
| 2836 | pathOut = path[i:] |
| 2837 | name = path[1:i] |
| 2838 | break |
| 2839 | } |
| 2840 | } |
| 2841 | switch strings.ToLower(name) { |
| 2842 | case "true", "false", "null", "nan", "inf": |
| 2843 | return pathOut, name, true |
| 2844 | } |
| 2845 | return pathOut, res, false |
| 2846 | } |
| 2847 | |
| 2848 | // execModifier parses the path to find a matching modifier function. |
| 2849 | // The input expects that the path already starts with a '@' |
no test coverage detected
searching dependent graphs…