MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / formatAsJSON

Function formatAsJSON

src/utils/sqlExport.ts:24–33  ·  view source on GitHub ↗
(data: SQLExportData)

Source from the content-addressed store, hash-verified

22 * 将 SQL 结果格式化为 JSON(数组对象形式)
23 */
24export function formatAsJSON(data: SQLExportData): string {
25 const jsonData = data.rows.map((row) => {
26 const obj: Record<string, unknown> = {}
27 data.columns.forEach((col, idx) => {
28 obj[col] = row[idx]
29 })
30 return obj
31 })
32 return JSON.stringify(jsonData, null, 2)
33}
34
35/**
36 * 导出 SQL 结果到文件

Callers 1

exportSQLResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected