MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_json

Method from_json

atomic-agent/src/hook_log.rs:55–75  ·  view source on GitHub ↗
(value: Option<&serde_json::Value>)

Source from the content-addressed store, hash-verified

53 }
54
55 fn from_json(value: Option<&serde_json::Value>) -> Self {
56 fn field(value: Option<&serde_json::Value>, names: &[&str]) -> Option<String> {
57 names
58 .iter()
59 .find_map(|name| usable(value?.get(name)?.as_str()))
60 }
61 let nested = value.and_then(|value| value.get("raw_json"));
62 Self {
63 session_id: field(
64 value,
65 &["session_id", "sessionID", "thread-id", "conversation_id"],
66 ),
67 parent_session_id: field(value, &["parent_session_id", "parentSessionID", "parentID"])
68 .or_else(|| {
69 field(
70 nested,
71 &["parent_session_id", "parentSessionID", "parentID"],
72 )
73 }),
74 }
75 }
76}
77
78#[derive(Default)]

Callers

nothing calls this directly

Calls 2

getMethod · 0.65
fieldFunction · 0.50

Tested by

no test coverage detected