How to return a complete object having the array elements as elements of an object

this is the start of the object , i should be able to call the elements of celldata.values

var generatedObj1 = {
      "agg": "Glossar",
      "ifa": null,
      "ifv": null,
      "ird": null,
      "afv": null,
      "ard": null,
      "metaData": {
        "cellMetaDataList": [{
          "cell": "glossar", // <-- cell type 
          "cmv": null,
          "crd": null,
          "logicalData": {
            "body": [{
                "id": "f5d", // <-- body id 1
                "name": "name", // <-- attribute name 1
                "minLength": 3,
                "maxLength": 100,
                "minValue": null,
                "maxValue": null,
                "wertebereich": "ALPHANUMERISCH",
                "validationCode": "",
                "exampleValues": ["Langer Name", "Kurzer Name", "Kein Name"]
              },
              {
                "id": "42", // <-- body id 2
                "name": "kurzname", // <-- attribute name 2
                "minLength": 3,
                "maxLength": 20,
                "minValue": null,
                "maxValue": null,
                "wertebereich": "ALPHANUMERISCH",
                "validationCode": "",
                "exampleValues": ["long_desc", "short_desc", "no_desc"]
              },
              {
                "id": "9d", // <-- body id 3
                "name": "eindeutig", // <-- attribute name 3
                "minLength": 1,
                "maxLength": 1,
                "minValue": null,
                "maxValue": null,
                "wertebereich": "WAHRHEITSWERT",
                "validationCode": "",
                "exampleValues": [true, false]
              }
            ]
          }
        }]
      },
      "data": {
        "cellData": [{ // row 1 from res1
            "cell": "glossar", // <-- cell type 
            "id": "5b", // <- UUID v4 (generated by the function)
            "cmv": null,
            "crd": null,
            "caption": {
              "pers": "string",
              "custNr": "string",
              "fnam": "string",
              "snam": "string",
              "sysId": "string"
            },
            "values": [{
                "name": "name", // <-- attribute name 1
                "value": "Langer Name",
                "bodyRefId": "5d" // <-- body id 1
              },
              {
                "name": "kurzname", // <-- attribute name 2
                "value": "no_desc",
                "bodyRefId": "42" // <-- body id 2
              },
              {
                "name": "eindeutig", // <-- attribute name 3
                "value": false,
                "bodyRefId": "9d" // <-- body id 3
              }
            ]
          },
          { // row 2 from res1
            "cell": "glossar", // <-- cell type 
            "id": "5c", // <- UUID v4 (generated by the function)
            "cmv": null,
            "crd": null,
            "caption": {
              "pers": "string",
              "custNr": "string",
              "fnam": "string",
              "snam": "string",
              "sysId": "string"
            },
            "values": [{
                "name": "name", // <-- attribute name 1
                "value": "Kein Name",
                "bodyRefId": "5d" // <-- body id 1
              },
              {
                "name": "kurzname", // <-- attribute name 2
                "value": "short_desc",
                "bodyRefId": "42" // <-- body id 2
              },
              {
                "name": "eindeutig", // <-- attribute name 3
                "value": true,
                "bodyRefId": "9d" // <-- body id 3
              }
            ]
          },
          { // row 3 from res1
            "cell": "glossar", // <-- cell type 
            "id": "5d", // <- UUID v4 (generated by the function)
            "cmv": null,
            "crd": null,
            "caption": {
              "pers": "string",
              "custNr": "string",
              "fnam": "string",
              "snam": "string",
              "sysId": "string"
            },
            "values": [{
                "name": "name", // <-- attribute name 1
                "value": "Kurzer Name",
                "bodyRefId": "5d" // <-- body id 1
              },
              {
                "name": "kurzname", // <-- attribute name 2
                "value": "short_desc",
                "bodyRefId": "42" // <-- body id 2
              },
              {
                "name": "eindeutig", // <-- attribute name 3
                "value": true,
                "bodyRefId": "9d" // <-- body id 3
              }
            ]
          }
        ]
      }
    }
'
one should be able to call the celldata.values in a function below 
 
      function add(input1) {
        let exampleValues1 = input1.metaData.cellMetaDataList[0].logicalData.body.map(({
          exampleValues
        }) => exampleValues);

        return comb(exampleValues1,20);
      }
sample result 
[
                ["Langer Name", "no_desc", false],
                       ["Kein Name", "short_desc", true]
                 ["Kurzer Name", "short_desc", true]
                   ];

instead of returning a simple arrray as the out put , should return a complete object having array elements as elements of an cellData values object .
how can i implement it in the function add ?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like