| 85 | $.done(result) |
| 86 | }) |
| 87 | function parseJsonPath(_path) { |
| 88 | const path = _path.trim() |
| 89 | const output = [] |
| 90 | const regex = /\.?([^\.\[\]]+)|\[(['"])(.*?)\2\]|\[(\d+)\]/g |
| 91 | let match |
| 92 | |
| 93 | while ((match = regex.exec(path)) !== null) { |
| 94 | if (match[1] !== undefined) { |
| 95 | // 匹配点符号或初始键 |
| 96 | output.push(match[1]) |
| 97 | } else if (match[3] !== undefined) { |
| 98 | // 匹配带引号的括号表示法 |
| 99 | output.push(match[3]) |
| 100 | } else if (match[4] !== undefined) { |
| 101 | // 数组索引,转换为整数 |
| 102 | output.push(parseInt(match[4], 10)) |
| 103 | } |
| 104 | } |
| 105 | return output |
| 106 | } |
| 107 | function unset(object, path) { |
| 108 | if (object == null) { |
| 109 | return true |