MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / ReadObjectOrDefault

Method ReadObjectOrDefault

ui/Services/ModeService.cs:124–137  ·  view source on GitHub ↗
(string path, bool skipComments)

Source from the content-addressed store, hash-verified

122 }
123
124 private static JsonElement ReadObjectOrDefault(string path, bool skipComments)
125 {
126 if (!File.Exists(path)) return default;
127 try
128 {
129 var json = File.ReadAllText(path);
130 var opts = skipComments
131 ? new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }
132 : default;
133 using var doc = JsonDocument.Parse(json, opts);
134 return doc.RootElement.Clone();
135 }
136 catch { return default; }
137 }
138
139 private static void CopyExcept(JsonElement obj, string skipKey, Utf8JsonWriter writer)
140 {

Callers

nothing calls this directly

Calls 1

ParseMethod · 0.80

Tested by

no test coverage detected