Javascript Json对象在单个数组中,需要使用key meta_值拆分键上的值

Javascript Json对象在单个数组中,需要使用key meta_值拆分键上的值,javascript,arrays,json,split,javascript-objects,Javascript,Arrays,Json,Split,Javascript Objects,我在一个数组中有一个json对象,这是一个原始文件,我已经删除了一些字段,现在我想为每个条目修改一个键值。下面是一些Json示例。我想在http://www.website/wp-content/uploads/ 现在,我的代码返回每个未定义的meta_值,而不是拆分值,我认为这与循环更改键值并尝试拆分它有关 任何帮助都将不胜感激 这是我到目前为止所拥有的代码,它在最后生成json数据 var exclusions = [ "ID", "post_author", "post_date_gmt"

我在一个数组中有一个json对象,这是一个原始文件,我已经删除了一些字段,现在我想为每个条目修改一个键值。下面是一些Json示例。我想在
http://www.website/wp-content/uploads/
现在,我的代码返回每个未定义的meta_值,而不是拆分值,我认为这与循环更改键值并尝试拆分它有关

任何帮助都将不胜感激

这是我到目前为止所拥有的代码,它在最后生成json数据

var exclusions = [
"ID", "post_author", "post_date_gmt", "post_excerpt", "comment_status", 
"ping_status", "post_password", "to_ping" ,"pinged", "post_modified","post_name",
"post_modified_gmt", "post_content_filtered", "guid", "menu_order", "post_mime_type",
"comment_count", "meta_id", "post_id", "post_type", "post_status"
];
var a = JSON.parse(fs.readFileSync('final.json'));

a.forEach(obj=>{
  exclusions.forEach(excl=>{
    if(obj[excl] || obj[excl] === ""){
      delete obj[excl];
    }

    if(obj["meta_value"] !== undefined){

      let objTest = obj["meta_value"].split('http://www.fsd.ca/wp-content/uploads/')[1];

      obj["meta_value"] = objTest;


    }

  });
});

console.log(a);
初始排除后的Json

[
  {
    post_date: '2012-02-16 23:37:22',
    post_content: `Today we worked at literacy centres. We are writing our own Three Bears story. We are reading with Mrs.Kitson, writing in our life books, working in our printing books and working on making words on the iPads. We use the apps Pocket phonics, magnet board and Montessori crosswords. We went to the library. In the afternoon we went to the gym and watched a play by Quest Theatre. It was called <span style="text-decoration: underline;">For</span> <span style="text-decoration: underline;">Art's Sake.</span> They told us that we are all artists and that we should use our imagination. We did zumba. We danced to The chihuahua song. We went to the DPA room and played different tag games. Our hearts worked hard. We had a fun day!`,
    post_title: 'Hometime',
    meta_value: 'http://www.fsd
[
{
发布日期:“2012-02-16 23:37:22”,
post_内容:`今天我们在扫盲中心工作。我们正在写我们自己的三只熊的故事。我们正在和Kitson夫人一起阅读,在我们的生活书籍中写作,在我们的印刷书籍中工作,并在iPad上制作单词。我们使用应用程序Pocket phonics、Magnetboard和Montessori纵横字谜。我们去了图书馆。下午我们去了图书馆去了健身房,看了Quest剧院的一场戏。这场戏是为了艺术。他们告诉我们,我们都是艺术家,应该发挥我们的想象力。我们做了尊巴。我们跟着吉娃娃的歌跳舞。我们去了DPA室,玩了不同的标签游戏。我们的心在努力工作。我们度过了愉快的一天,
post_标题:“Hometime”,
元值:'http://www.fsd
  • 列表项
  • .ca/wp content/uploads/2012/02/SN850631.jpg' }, { 发布日期:“2012-02-21 20:39:19”, post_内容:“今天我们开始建造城堡。我们用彩色纸巾把它们涂成彩色。我们正在写我们自己的童话。我们在读青蛙公主童话。我们在做泥龙和缝纫木偶。我们去了健身房,跳过了。我们在生活书中写了一篇文章,并练习了印刷。我们度过了一个快乐的一天!”, 帖子标题:“创建城堡”, 元值:“” }, { 发布日期:“2012-02-23 21:30:55”, post_内容:“我们讨论了字母E。E是一个元音。每个单词中都有一个元音。我们做了电子表格。我们去滑冰。滑冰后我们吃了热巧克力。我们在新的识字中心工作。我们在做艰苦的工作。我们去了音乐。我们玩了大黄蜂游戏。我们去了DPA室玩标签和舞蹈。我们去了中心和学校图书馆,我们玩得很开心, 帖子标题:“我们有了新枕头”, 元值:“” }, { 发布日期:“2012-02-2419:06:39”, post_内容:“今天是夏威夷节。我们穿着短裤和夏装。我们制作了一张Chicka Chicka Boom Boom图片。我们制作了leis。我们吃了蘸面糊的菠萝,吃了芒果、菠萝、木瓜、红果、龙果和椰子。我们尝试了椰子水。我们做了悬崖边舞,跳了夏威夷式的舞。我们坐在毛巾上,玩了一个数学游戏我们猜了一下杯子下面有多少糖果。我们在生活书上写了些东西,然后去了大公园。我们玩得很开心,很开心, 邮政标题:“夏威夷日”, 元值:“” }, …还有654件 ]

    Json meta_值键值更改后,每个值都未定义

        [
    {
        post_date: '2012-02-16 23:37:22',
        post_content: `Today we worked at literacy centres. We are writing our own Three Bears story. We are reading with Mrs.Kitson, writing in our life books, working in our printing books and working on making words on the iPads. We use the apps Pocket phonics, magnet board and Montessori crosswords. We went to the library. In the afternoon we went to the gym and watched a play by Quest Theatre. It was called <span style="text-decoration: underline;">For</span> <span style="text-decoration: underline;">Art's Sake.</span> They told us that we are all artists and that we should use our imagination. We did zumba. We danced to The chihuahua song. We went to the DPA room and played different tag games. Our hearts worked hard. We had a fun day!`,
        post_title: 'Hometime',
        meta_value: undefined
      },
      {
        post_date: '2012-02-21 20:39:19',
        post_content: 'Today we started making our castles. We painted them colourful tissue paper. We are writing our own fairy tales. We read The Princess Frog Fairy Tale. We are making clay dragons and sewing puppets. We went to the gym and skipped. We wrote in our life books an practiced our printing. We had a fun day!',
        post_title: 'Creating Castles',
        meta_value: undefined
      },
      {
        post_date: '2012-02-23 21:30:55',
        post_content: 'We talked about the letter E. E is a vowel. There is a vowel in every word. We did our E sheets. We went skating. We had hot chocolate after skating. We worked at new literacy centers. We are doing hard work. We went to Music. We played the bumble bee game. We went to the DPA room to play tag and dance. We went to centers and to the library. We had a fun day!',
        post_title: 'We Have New Pillows',
        meta_value: undefined
      },
      {
        post_date: '2012-02-24 19:06:39',
        post_content: 'Today it was Hawaii Day. We wore shorts and summer clothes. We made a Chicka Chicka Boom Boom picture. We made leis. We ate batter dipped pineapples and ate mango, pineapple, papaya, starfruit, dragon fruit and coconut. We tried coconut water. We did the limbo and danced Hawaii style. We sat on our towels and played a math game where we guessed how many candies were under the cup. We wrote in our life books and we went to the big park. We had a fun, fun day!',
        post_title: 'Hawaii Day',
        meta_value: undefined
      },
      ... 654 more items
    ]
    
    [
    {
    发布日期:“2012-02-16 23:37:22”,
    post_内容:`今天我们在扫盲中心工作。我们正在写我们自己的三只熊的故事。我们正在和Kitson夫人一起阅读,在我们的生活书籍中写作,在我们的印刷书籍中工作,并在iPad上制作单词。我们使用应用程序Pocket phonics、Magnetboard和Montessori纵横字谜。我们去了图书馆。下午我们去了图书馆去了健身房,看了Quest剧院的一场戏。这场戏是为了艺术。他们告诉我们,我们都是艺术家,应该发挥我们的想象力。我们做了尊巴。我们跟着吉娃娃的歌跳舞。我们去了DPA室,玩了不同的标签游戏。我们的心在努力工作。我们度过了愉快的一天,
    post_标题:“Hometime”,
    meta_值:未定义
    },
    {
    发布日期:“2012-02-21 20:39:19”,
    post_内容:“今天我们开始建造城堡。我们用彩色纸巾把它们涂成彩色。我们正在写我们自己的童话。我们在读青蛙公主童话。我们在做泥龙和缝纫木偶。我们去了健身房,跳过了。我们在生活书中写了一篇文章,并练习了印刷。我们度过了一个快乐的一天!”,
    帖子标题:“创建城堡”,
    meta_值:未定义
    },
    {
    发布日期:“2012-02-23 21:30:55”,
    post_内容:“我们讨论了字母E。E是一个元音。每个单词中都有一个元音。我们做了电子表格。我们去滑冰。滑冰后我们吃了热巧克力。我们在新的识字中心工作。我们在做艰苦的工作。我们去了音乐。我们玩了大黄蜂游戏。我们去了DPA室玩标签和舞蹈。我们去了中心和学校图书馆,我们玩得很开心,
    帖子标题:“我们有了新枕头”,
    meta_值:未定义
    },
    {
    发布日期:“2012-02-2419:06:39”,
    post_内容:“今天是夏威夷节。我们穿着短裤和夏装。我们制作了一张Chicka Chicka Boom Boom图片。我们制作了leis。我们吃了蘸面糊的菠萝,吃了芒果、菠萝、木瓜、红果、龙果和椰子。我们尝试了椰子水。我们做了悬崖边舞,跳了夏威夷式的舞。我们坐在毛巾上,玩了一个数学游戏我们猜了一下杯子下面有多少糖果。我们在生活书上写了些东西,然后去了大公园。我们玩得很开心,很开心,
    邮政标题:“夏威夷日”,
    meta_值:未定义
    },
    …还有654件
    ]
    
    在下一行 设objTest=obj[“meta_值”]。拆分(“”)[1]; 当您使用split()时,它返回空数组,并且第0个元素的[]不存在。

    在下行 设objTest=obj[“meta_值”]。拆分(“”)[1];
    使用split()时,它会返回空数组,并且第0个元素的[]不存在。

    问题在于,在
    排除.forEach()循环中,有代码要更改
    obj[“meta_值”]
    。所以它运行的是m