Read zero or more JSON objects from a string, without requiring each of them to be on its own line. For example: { "name": "First Object" }{"name": "Second Object"}
(s: str)
| 70 | |
| 71 | |
| 72 | def multi_json(s: str) -> list[dict[Any, Any]]: |
| 73 | """Read zero or more JSON objects from a string, |
| 74 | without requiring each of them to be on its own line. |
| 75 | |
| 76 | For example: |
| 77 | { |
| 78 | "name": "First Object" |
| 79 | }{"name": "Second Object"} |
| 80 | """ |
| 81 | |
| 82 | decoder = json.JSONDecoder() |
| 83 | idx = 0 |
| 84 | result = [] |
| 85 | while idx < len(s): |
| 86 | if s[idx] in " \t\n\r": |
| 87 | idx += 1 |
| 88 | else: |
| 89 | obj, idx = decoder.raw_decode(s, idx) |
| 90 | result.append(obj) |
| 91 | |
| 92 | return result |
| 93 | |
| 94 | |
| 95 | def load_machine_descs( |
no test coverage detected