How to display nested data in the grid

How to display nested data in the grid

imrakimrak Posts: 1Questions: 1Answers: 0

The data is below. All my contents are in products: How do I display this in the data table

{
  "formatVersion" : "v1.0",
  "version" : "20180131042456",
  "publicationDate" : "2018-01-31T04:24:56Z",
  "products" : {
    "HYZTQKMNAKH6FG9C" : {
      "sku" : "HYZTQKMNAKH6FG9C",
      "productFamily" : "Compute Instance",
      "attributes" : {
        "servicecode" : "AmazonEC2",
        "location" : "US East (N. Virginia)",
        "locationType" : "AWS Region",
        "instanceType" : "c5.9xlarge",
        "currentGeneration" : "Yes",
        "instanceFamily" : "Compute optimized",
        "vcpu" : "36",
        "physicalProcessor" : "Intel Xeon Platinum 8124M",
        "clockSpeed" : "3.0 Ghz",
        "memory" : "72 GiB",
        "storage" : "EBS only",
        "networkPerformance" : "10 Gigabit",
        "processorArchitecture" : "64-bit",
        "tenancy" : "Dedicated",
        "operatingSystem" : "RHEL",
        "licenseModel" : "No License required",
        "usagetype" : "DedicatedUsage:c5.9xlarge",
        "operation" : "RunInstances:0010",
        "dedicatedEbsThroughput" : "4500 Mbps",
        "ecu" : "139",
        "enhancedNetworkingSupported" : "Yes",
        "normalizationSizeFactor" : "72",
        "preInstalledSw" : "NA",
        "processorFeatures" : "Intel AVX, Intel AVX2, Intel AVX512, Intel Turbo",
        "servicename" : "Amazon Elastic Compute Cloud"
      }
    },
    "2BEAK4F883TCCQMS" : {
      "sku" : "2BEAK4F883TCCQMS",
      "productFamily" : "Compute Instance",
      "attributes" : {
        "servicecode" : "AmazonEC2",
        "location" : "US East (N. Virginia)",
        "locationType" : "AWS Region",
        "instanceType" : "x1e.xlarge",
        "currentGeneration" : "Yes",
        "instanceFamily" : "Memory optimized",
        "vcpu" : "4",
        "physicalProcessor" : "High Frequency Intel Xeon E7-8880 v3 (Haswell)",
        "clockSpeed" : "2.3 GHz",
        "memory" : "122 GiB",
        "storage" : "1 x 120",
        "networkPerformance" : "Up to 10 Gigabit",
        "processorArchitecture" : "64-bit",
        "tenancy" : "Dedicated",
        "operatingSystem" : "Windows",
        "licenseModel" : "No License required",
        "usagetype" : "DedicatedUsage:x1e.xlarge",
        "operation" : "RunInstances:0102",
        "dedicatedEbsThroughput" : "500 Mbps",
        "ecu" : "12",
        "enhancedNetworkingSupported" : "Yes",
        "intelAvxAvailable" : "Yes",
        "intelAvx2Available" : "Yes",
        "normalizationSizeFactor" : "8",
        "preInstalledSw" : "SQL Ent",
        "processorFeatures" : "Intel AVX, Intel AVX2",
        "servicename" : "Amazon Elastic Compute Cloud"
      }
    }
  }
}

Answers

  • kthorngrenkthorngren Posts: 21,302Questions: 26Answers: 4,947
    edited February 2018

    I see three things...

    1. Assuming you will be using the Datatables ajax option to fetch the data you will use ajax.dataSrc to tell Datatables where the data is. For example: dataSrc: "products"

    2. You have a nested JSON structure. This example will show you have to configure Datatables to access the different object levels:
      https://datatables.net/examples/ajax/deep.html

    3. products contains an object. Datatables expects an array of objects, more like this:
      EDIT: More info about data structure here:
      https://datatables.net/manual/data/#Data-source-types

    {
      "formatVersion" : "v1.0",
      "version" : "20180131042456",
      "publicationDate" : "2018-01-31T04:24:56Z",
      "products" : [
        {
          "sku" : "HYZTQKMNAKH6FG9C",
          "productFamily" : "Compute Instance",
          "attributes" : {
            "servicecode" : "AmazonEC2",
            "location" : "US East (N. Virginia)",
            "locationType" : "AWS Region",
            "instanceType" : "c5.9xlarge",
            "currentGeneration" : "Yes",
            "instanceFamily" : "Compute optimized",
            "vcpu" : "36",
            "physicalProcessor" : "Intel Xeon Platinum 8124M",
            "clockSpeed" : "3.0 Ghz",
            "memory" : "72 GiB",
            "storage" : "EBS only",
            "networkPerformance" : "10 Gigabit",
            "processorArchitecture" : "64-bit",
            "tenancy" : "Dedicated",
            "operatingSystem" : "RHEL",
            "licenseModel" : "No License required",
            "usagetype" : "DedicatedUsage:c5.9xlarge",
            "operation" : "RunInstances:0010",
            "dedicatedEbsThroughput" : "4500 Mbps",
            "ecu" : "139",
            "enhancedNetworkingSupported" : "Yes",
            "normalizationSizeFactor" : "72",
            "preInstalledSw" : "NA",
            "processorFeatures" : "Intel AVX, Intel AVX2, Intel AVX512, Intel Turbo",
            "servicename" : "Amazon Elastic Compute Cloud"
          }
        },
        {
          "sku" : "2BEAK4F883TCCQMS",
          "productFamily" : "Compute Instance",
          "attributes" : {
            "servicecode" : "AmazonEC2",
            "location" : "US East (N. Virginia)",
            "locationType" : "AWS Region",
            "instanceType" : "x1e.xlarge",
            "currentGeneration" : "Yes",
            "instanceFamily" : "Memory optimized",
            "vcpu" : "4",
            "physicalProcessor" : "High Frequency Intel Xeon E7-8880 v3 (Haswell)",
            "clockSpeed" : "2.3 GHz",
            "memory" : "122 GiB",
            "storage" : "1 x 120",
            "networkPerformance" : "Up to 10 Gigabit",
            "processorArchitecture" : "64-bit",
            "tenancy" : "Dedicated",
            "operatingSystem" : "Windows",
            "licenseModel" : "No License required",
            "usagetype" : "DedicatedUsage:x1e.xlarge",
            "operation" : "RunInstances:0102",
            "dedicatedEbsThroughput" : "500 Mbps",
            "ecu" : "12",
            "enhancedNetworkingSupported" : "Yes",
            "intelAvxAvailable" : "Yes",
            "intelAvx2Available" : "Yes",
            "normalizationSizeFactor" : "8",
            "preInstalledSw" : "SQL Ent",
            "processorFeatures" : "Intel AVX, Intel AVX2",
            "servicename" : "Amazon Elastic Compute Cloud"
          }
        }
      ]
    }
    

    Kevin

This discussion has been closed.