(_path)
| 2882 | } |
| 2883 | } |
| 2884 | function parseJsonPath(_path) { |
| 2885 | const path = _path.trim() |
| 2886 | const output = [] |
| 2887 | const regex = /\.?([^\.\[\]]+)|\[(['"])(.*?)\2\]|\[(\d+)\]/g |
| 2888 | let match |
| 2889 | |
| 2890 | while ((match = regex.exec(path)) !== null) { |
| 2891 | if (match[1] !== undefined) { |
| 2892 | // 匹配点符号或初始键 |
| 2893 | output.push(match[1]) |
| 2894 | } else if (match[3] !== undefined) { |
| 2895 | // 匹配带引号的括号表示法 |
| 2896 | output.push(match[3]) |
| 2897 | } else if (match[4] !== undefined) { |
| 2898 | // 数组索引,转换为整数 |
| 2899 | output.push(parseInt(match[4], 10)) |
| 2900 | } |
| 2901 | } |
| 2902 | return output |
| 2903 | } |
| 2904 | |
| 2905 | // 解析规则 |
| 2906 | function parseRule(input) { |
no outgoing calls
no test coverage detected