MCPcopy Create free account
hub / github.com/AI45Lab/Code / json_value

Method json_value

core/tests/test_persisted_schema_roundtrip.rs:151–171  ·  view source on GitHub ↗

Small `serde_json::Value` whose re-serialization is order-stable (object keys are fixed and few).

(&mut self, depth: u8)

Source from the content-addressed store, hash-verified

149 /// Small `serde_json::Value` whose re-serialization is order-stable
150 /// (object keys are fixed and few).
151 fn json_value(&mut self, depth: u8) -> serde_json::Value {
152 use serde_json::Value;
153 match self.below(if depth == 0 { 4 } else { 6 }) {
154 0 => Value::Null,
155 1 => Value::Bool(self.boolean()),
156 2 => Value::from(self.i32_small()),
157 3 => Value::from(self.string()),
158 4 => {
159 let n = self.below(3);
160 Value::Array((0..n).map(|_| self.json_value(depth - 1)).collect())
161 }
162 _ => {
163 let mut map = serde_json::Map::new();
164 map.insert("k0".into(), self.json_value(depth - 1));
165 if self.boolean() {
166 map.insert("k1".into(), Value::from(self.string()));
167 }
168 Value::Object(map)
169 }
170 }
171 }
172 /// Like [`json_value`], but never a top-level JSON `null`.
173 ///
174 /// For an `Option<serde_json::Value>` field, serde collapses

Callers 3

json_value_non_nullMethod · 0.80
gen_content_blockFunction · 0.80
gen_subagent_taskFunction · 0.80

Calls 5

belowMethod · 0.80
booleanMethod · 0.80
i32_smallMethod · 0.80
stringMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected