diff --git a/src/components/json-schema-editor/index.vue b/src/components/json-schema-editor/index.vue index 5c63c10..3fb477f 100644 --- a/src/components/json-schema-editor/index.vue +++ b/src/components/json-schema-editor/index.vue @@ -193,6 +193,9 @@ function nodeToValue(node: JsonNodeData): any { else if (node.type === 'boolean') rawValue = node.primitiveValue === true || node.primitiveValue === 'true'; else rawValue = String(node.primitiveValue); + // 最外层根 object 不套 { type, attrs },直接返回原始对象 + if (node === rootNode.value) return rawValue; + // 容器类型(object/array)始终输出 { type, attrs, ...config } if (node.type === 'object' || node.type === 'array') { const result: Record = { type: node.type, attrs: rawValue }; @@ -205,10 +208,10 @@ function nodeToValue(node: JsonNodeData): any { // 标量类型也始终输出 { type, value, ...config } const result: Record = { type: node.type, value: rawValue }; if (node.config && hasAnyConfig(node)) { - Object.assign(result, node.config); + Object.assign(result, node.config); + } + return result; } - return result; -} function defaultFormType(jsonType: string): string { const m: Record = { string: 'string', number: 'number', boolean: 'switch' };