File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -369,7 +369,8 @@ function buildInnerObject (context, location) {
369369 code += 'let json = JSON_STR_BEGIN_OBJECT\n'
370370
371371 let addComma = ''
372- if ( ! hasRequiredProperties && ( propertiesKeys . length > 1 || ( schema . patternProperties || schema . additionalProperties ) ) ) {
372+ const hasComma = ! hasRequiredProperties && ( propertiesKeys . length > 1 || ( schema . patternProperties || schema . additionalProperties ) )
373+ if ( hasComma ) {
373374 code += 'let addComma = false\n'
374375 addComma = '!addComma && (addComma = true) || (json += JSON_STR_COMMA)'
375376 }
@@ -387,14 +388,14 @@ function buildInnerObject (context, location) {
387388 code += `
388389 value = obj[${ sanitizedKey } ]
389390 if (value !== undefined) {
390- ${ addComma }
391+ ${ i > 0 ? addComma : ( hasComma ? 'addComma = true' : '' ) }
391392 json += ${ JSON . stringify ( sanitizedKey + ':' ) }
392393 ${ buildValue ( context , propertyLocation , 'value' ) }
393394 }`
394395
395396 if ( defaultValue !== undefined ) {
396397 code += ` else {
397- ${ addComma }
398+ ${ i > 0 ? addComma : ( hasComma ? 'addComma = true' : '' ) }
398399 json += ${ JSON . stringify ( sanitizedKey + ':' + JSON . stringify ( defaultValue ) ) }
399400 }
400401 `
You can’t perform that action at this time.
0 commit comments