Extract array from data using simple dot notation path.
(self, data: Any)
| 130 | self.json_path = json_path |
| 131 | |
| 132 | def _extract_array(self, data: Any) -> List[Any]: |
| 133 | """Extract array from data using simple dot notation path.""" |
| 134 | if not self.json_path: |
| 135 | if isinstance(data, list): |
| 136 | return data |
| 137 | return [data] |
| 138 | |
| 139 | parts = self.json_path.split(".") |
| 140 | current = data |
| 141 | |
| 142 | for part in parts: |
| 143 | if isinstance(current, dict): |
| 144 | current = current.get(part) |
| 145 | elif isinstance(current, list) and part.isdigit(): |
| 146 | idx = int(part) |
| 147 | current = current[idx] if idx < len(current) else None |
| 148 | else: |
| 149 | return [] |
| 150 | |
| 151 | if current is None: |
| 152 | return [] |
| 153 | |
| 154 | if isinstance(current, list): |
| 155 | return current |
| 156 | return [current] |
| 157 | |
| 158 | def split(self, inputs: List[Message]) -> List[List[Message]]: |
| 159 | """Split by extracting array items from JSON content.""" |