(self)
| 585 | return result |
| 586 | |
| 587 | def unique_dict(self) -> t.Dict[str, 'JsonObject']: |
| 588 | if type(self.val) is list and self.is_dict: |
| 589 | result = {} |
| 590 | for child in self.val: |
| 591 | if child.key is None: |
| 592 | raise ValueError("empty key in dict") |
| 593 | |
| 594 | def __expand_child(child: 'JsonObject'): |
| 595 | if type(child.val) is list and child.is_dict: # dict case |
| 596 | return child |
| 597 | elif type(child.val) is list: # list case |
| 598 | return [__expand_child(c) for c in child.val] |
| 599 | else: |
| 600 | return child.val |
| 601 | |
| 602 | result[child.key] = __expand_child(child) |
| 603 | return result |
| 604 | else: |
| 605 | raise ValueError("unique_dict() only works for dict") |
| 606 | |
| 607 | |
| 608 | def json_object_pairs_hook(data: t.List[t.Tuple[str, object]]) -> JsonObject: |
no test coverage detected