将js对象属性映射到其他值

时间:2019-07-16 18:56:41

标签: javascript json object javascript-objects

我正在开发一个Web应用程序,其中必须在网页上显示多个长json数据集。每个json对象都有多个属性。 返回的每个属性都是一个解析为不同值的代码(来自一组大约1700个值)。

就在我在网页上显示属性之前,尝试将属性(代码)与我拥有的一组值(总计〜1700)进行匹配。 由于要映射的属性超过5000个,因此Webapp变得非常慢。有时需要花费一分钟多的时间才能呈现网页。

最理想的方法是使渲染时间最小化。

JSON数据如下:

{
  "portId": "9501",
  "newAttribute": "new attribute",
  "bmHlgdBrkdn": [
    {
      "bmId": "1",
      "bmAssocType": "one",
      "applicableName": "one",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "11",
      "bmAssocType": "one",
      "applicableName": "one",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "2",
      "bmAssocType": "two",
      "applicableName": "two",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "3",
      "bmAssocType": "three",
      "applicableName": "three",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "33",
      "bmAssocType": "three",
      "applicableName": "three",
      "bmHldgBrnknItem": [
          {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "22",
      "bmAssocType": "two",
      "applicableName": "two",
      "bmHldgBrnknItem": [
          {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    }
  ]
}{
  "portId": "9501",
  "newAttribute": "new attribute",
  "bmHlgdBrkdn": [
    {
      "bmId": "1",
      "bmAssocType": "one",
      "applicableName": "one",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "11",
      "bmAssocType": "one",
      "applicableName": "one",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "2",
      "bmAssocType": "two",
      "applicableName": "two",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "3",
      "bmAssocType": "three",
      "applicableName": "three",
      "bmHldgBrnknItem": [
        {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "33",
      "bmAssocType": "three",
      "applicableName": "three",
      "bmHldgBrnknItem": [
          {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    },
    {
      "bmId": "22",
      "bmAssocType": "two",
      "applicableName": "two",
      "bmHldgBrnknItem": [
          {
          "creditRatingID": "AA",
          "shortName": "AA",
          "longName": "AA",
          "value": "abc"
        }
      ]
    }
  ]
}

这是上面返回的属性映射到的键-值对的示例:

{
  "portId": "Port ID",
  "longName": "Long Name",
  "shortName": "Short Name",
  "prospectusFundFullName": "Prospectus Fund Full Name",
  "bmId": "Benchmark ID",
  "bmAssocType": "Benchmark Association Type",
  "bmLongName": "Benchmark Long Name",
  ............
  ............
}

0 个答案:

没有答案
相关问题