MCPcopy Create free account
hub / github.com/zxlie/FeHelper / buildJsonStructureSummary

Function buildJsonStructureSummary

apps/json-format/index.js:181–212  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

179}
180
181function buildJsonStructureSummary(source) {
182 try {
183 const jsonObj = parseWithBigInt(source);
184 const stats = {
185 rootType: getJsonValueType(jsonObj),
186 nodes: 0,
187 objects: 0,
188 arrays: 0,
189 objectNotes: [],
190 arrayNotes: [],
191 nullables: [],
192 optionalFields: [],
193 typeConflicts: [],
194 mixedArrays: [],
195 depthNotes: []
196 };
197 collectJsonStructureStats(jsonObj, '$', stats);
198 return [
199 `根类型: ${stats.rootType}`,
200 `扫描节点: ${stats.nodes},对象: ${stats.objects},数组: ${stats.arrays}`,
201 stats.objectNotes.length ? `对象结构: ${stats.objectNotes.join(';')}` : '',
202 stats.arrayNotes.length ? `数组结构: ${stats.arrayNotes.join(';')}` : '',
203 stats.nullables.length ? `nullable 字段: ${stats.nullables.join(';')}` : '',
204 stats.optionalFields.length ? `数组可选字段: ${stats.optionalFields.join(';')}` : '',
205 stats.typeConflicts.length ? `类型不稳定: ${stats.typeConflicts.join(';')}` : '',
206 stats.mixedArrays.length ? `混合数组: ${stats.mixedArrays.join(';')}` : '',
207 stats.depthNotes.length ? `深层结构: ${stats.depthNotes.join(';')}` : ''
208 ].filter(Boolean).join('\n');
209 } catch (error) {
210 return `本地结构摘要生成失败: ${error && error.message ? error.message : '未知错误'}`;
211 }
212}
213
214function isJsonDerivedAiTask(task) {
215 return Object.values(JSON_DERIVED_AI_TASKS).some(item => item.taskKey === task);

Callers 1

Calls 3

getJsonValueTypeFunction · 0.85
parseWithBigIntFunction · 0.70

Tested by

no test coverage detected