MCPcopy Create free account
hub / github.com/douglance/devsql / to_json_array

Method to_json_array

crates/vcsql/src/sql/engine.rs:211–222  ·  view source on GitHub ↗

Converts the result to a JSON array of objects. Each row becomes a JSON object with column names as keys.

(&self)

Source from the content-addressed store, hash-verified

209 ///
210 /// Each row becomes a JSON object with column names as keys.
211 pub fn to_json_array(&self) -> Vec<Value> {
212 self.rows
213 .iter()
214 .map(|row| {
215 let mut obj = Map::new();
216 for (i, col) in self.columns.iter().enumerate() {
217 obj.insert(col.clone(), row.get(i).cloned().unwrap_or(Value::Null));
218 }
219 Value::Object(obj)
220 })
221 .collect()
222 }
223}

Callers 3

format_jsonFunction · 0.80
format_jsonlFunction · 0.80

Calls

no outgoing calls

Tested by 1