MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / to_json

Method to_json

claw-code/rust/crates/runtime/src/session.rs:99–115  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

97
98 #[must_use]
99 pub fn to_json(&self) -> JsonValue {
100 let mut object = BTreeMap::new();
101 object.insert(
102 "version".to_string(),
103 JsonValue::Number(i64::from(self.version)),
104 );
105 object.insert(
106 "messages".to_string(),
107 JsonValue::Array(
108 self.messages
109 .iter()
110 .map(ConversationMessage::to_json)
111 .collect(),
112 ),
113 );
114 JsonValue::Object(object)
115 }
116
117 pub fn from_json(value: &JsonValue) -> Result<Self, SessionError> {
118 let object = value

Callers 1

save_to_pathMethod · 0.80

Calls 1

usage_to_jsonFunction · 0.85

Tested by

no test coverage detected