在地图期间比较JSON节点中的值

时间:2019-05-08 06:34:31

标签: javascript json

在映射JSON对象时可以在节点之间比较键值吗?

我想检测何时发生新的月份,并打印一个git push origin {remoteBranchName} ,其中包含月份。

我有一个类似JSON的对象:

<h1>

我正在像这样映射它:

[
    {
        "eventId": "1",
        "image": "https://images.com/jyik.jpg",
        "date": "Wednesday, May 17, 2019",
    },
    {
        "eventId": "2",
        "image": "https://images.com/aadag.jpg",
        "date": "Wednesday, May 19, 2019",
    },
    {
        "eventId": "3",
        "image": "https://images.com/rjdsrjt.jpg",
        "date": "Wednesday, May 26, 2019",
    },
    {
        "eventId": "4",
        "image": "https://images.com/cxvbfgbhy.jpg",
        "date": "Wednesday, Jun 2, 2019",
    },
    {
        "eventId": "5",
        "image": "https://images.com/asdf4.jpg",
        "date": "Wednesday, July 8, 2019",
    }
]

所以它就像:

// renderCalendarEvent function just builds the event div with event details.

fetch(calendarData).then(res => (res.json().then(data => data.map(event => renderCalendarEvent(event, data))).then((eventsMarkup) => {
    if (eventsNode) {
      var calendarPage = $('<div class="month-wrap"/>')[0];
      calendarPage.innerHTML = eventsMarkup.join('');
      eventsNode.append(calendarPage);

    }
  });

0 个答案:

没有答案