MCPcopy
hub / github.com/MinishLab/semble / _json5_object

Function _json5_object

src/semble/installer/config.py:37–47  ·  view source on GitHub ↗

Parse text as JSON5; return (object node, source bytes), "skipped" if grammar unavailable, or "error" if unparseable.

(text: str)

Source from the content-addressed store, hash-verified

35
36
37def _json5_object(text: str) -> JsonObjectResult:
38 """Parse text as JSON5; return (object node, source bytes), "skipped" if grammar unavailable, or "error" if unparseable."""
39 parser = _json5_parser()
40 if parser is None:
41 return "skipped"
42 src = text.encode("utf-8")
43 root = parser.parse(src).root_node
44 if root.has_error:
45 return "error"
46 objects = [c for c in root.named_children if c.type == "object"]
47 return (objects[0], src) if objects else "error"
48
49
50def _member(obj: Node, src: bytes, key: str) -> Node | None:

Callers 2

merge_json_memberFunction · 0.85
remove_json_memberFunction · 0.85

Calls 2

_json5_parserFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected