isJSONIdx reports whether the string represents a JSON index.
(s string)
| 692 | |
| 693 | // isJSONIdx reports whether the string represents a JSON index. |
| 694 | func isJSONIdx(s string) (string, bool) { |
| 695 | if len(s) > 2 && s[0] == '[' && s[len(s)-1] == ']' && (isNumber(s[1:len(s)-1]) || s[1] == '#' && isNumber(s[2:len(s)-1])) { |
| 696 | return s[1 : len(s)-1], true |
| 697 | } |
| 698 | return "", false |
| 699 | } |
| 700 | |
| 701 | // isNumber reports whether the string is a number (category N). |
| 702 | func isNumber(s string) bool { |
no test coverage detected
searching dependent graphs…