MCPcopy Create free account
hub / github.com/GCWing/BitFun / collect_json_string_stats

Function collect_json_string_stats

src/apps/desktop/src/api/agentic_api.rs:323–350  ·  view source on GitHub ↗
(value: &serde_json::Value, path: &str, stats: &mut JsonStringStats)

Source from the content-addressed store, hash-verified

321}
322
323fn collect_json_string_stats(value: &serde_json::Value, path: &str, stats: &mut JsonStringStats) {
324 match value {
325 serde_json::Value::String(text) => {
326 let char_count = text.chars().count();
327 stats.total_chars += char_count;
328 if char_count > stats.largest_chars {
329 stats.largest_chars = char_count;
330 stats.largest_path = path.to_string();
331 }
332 }
333 serde_json::Value::Array(items) => {
334 for (index, item) in items.iter().enumerate() {
335 collect_json_string_stats(item, &format!("{}[{}]", path, index), stats);
336 }
337 }
338 serde_json::Value::Object(map) => {
339 for (key, item) in map {
340 let next_path = if path.is_empty() {
341 key.to_string()
342 } else {
343 format!("{}.{}", path, key)
344 };
345 collect_json_string_stats(item, &next_path, stats);
346 }
347 }
348 _ => {}
349 }
350}
351
352fn push_top_raw_result(stats: &mut RestoreTurnPayloadStats, result: RestoreToolOutputStats) {
353 if result.raw_result_string_chars == 0 {

Callers 1

Calls 3

iterMethod · 0.80
countMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected