Skip to content

Commit be3e4dc

Browse files
refactor: enhance JSON handling in processFieldsRecursive function of aem.service.ts to support string and object types for content
1 parent 42fe960 commit be3e4dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

api/src/services/aem.service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,16 @@ function processFieldsRecursive(fields: any[], items: any, title: string, assetJ
513513
case 'json': {
514514
const value = items?.[field?.uid];
515515
const uid = getLastKey(field?.contentstackFieldUid);
516-
const jsonData = attachJsonRte({ content: value })
516+
517+
let htmlContent = '';
518+
519+
if (typeof value === 'string') {
520+
htmlContent = value;
521+
} else if (value && typeof value === 'object') {
522+
htmlContent = value.text || value.content || '';
523+
}
524+
525+
const jsonData = attachJsonRte({ content: htmlContent });
517526
obj[uid] = jsonData;
518527
break;
519528
}

0 commit comments

Comments
 (0)