MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / multi_json

Function multi_json

misc/python/materialize/cli/scratch/create.py:72–92  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

70
71
72def 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
95def load_machine_descs(

Callers 2

pick_machineFunction · 0.85
load_machine_descsFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected