我有一个嵌套对象,其中包含几个键,这些键还包括标题和子项。Children 是也具有标题和子键的对象数组。(它们看起来像一棵树)如何搜索和替换标题值的一个单词或一部分?
const object = {
id: 'uuid',
title: 'hello You',
type: number,
visibility: true,
children: [
{
id: 'uuid',
title: 'You don't have any comments...',
type: number,
visibility: true,
children: [{...}, {...}, ...],
key1: {...},
key2: [{...}]
},
{
id: 'uuid',
title: 'You your problem is not with json...',
type: number,
visibility: true,
children: [{...}, {...}, ...],
key1: {...},
key2: [{...}]
}
],
key1: {...},
key2: [{...}]
}
搜索you并替换world标题
output = {
id: 'uuid',
title: 'hello world',
type: number,
visibility: true,
children: [
{
id: 'uuid',
title: 'world don't have any comments...',
type: number,
visibility: true,
children: [{...}, {...}, ...],
key1: {...},
key2: [{...}]
},
{
id: 'uuid',
title: 'world your problem is not with json...',
type: number,
visibility: true,
children: [{...}, {...}, ...],
key1: {...},
key2: [{...}]
}
],
key1: {...},
key2: [{...}]
}
至尊宝的传说
相关分类