AWS Textract - run through data and get values?

Okay so following this YT tutorial: https://www.youtube.com/watch?v=wGAEAcfwV8w&

I’ve used Set node to get the ‘SummaryFields’ subset of data that I need (see OP) and set it as pdfdata.

[
  {
    "pdfdata": [
      {
        "Type": {
          "Text": "TOTAL",
          "Confidence": 89.66414642333984
        },
        "LabelDetection": {
          "Text": "TOTAL",
          "Confidence": 89.2239990234375
        },
        "ValueDetection": {
          "Text": "53900",
          "Confidence": 87.2876205444336
        },
        "PageNumber": 1
      },
      {
        "Type": {
          "Text": "INVOICE_RECEIPT_DATE",
          "Confidence": 95.58136749267578
        },
        "LabelDetection": {
          "Text": "INVOICE AND\nSUPPLY DATE",
          "Confidence": 95.3720474243164
        },
        "ValueDetection": {
          "Text": "04/04/2022",
          "Confidence": 94.0542984008789
        },
        "PageNumber": 1
      }
    ]
  }
]

I then created a new Function and used:

from here: How can I select part of json with Function or Set node - #4 by MutedJam

Then I turned it into this:

return [{
  json: {
    pdfdata: items[0].json.pdfdata.map(s => { return {
        name: s.LabelDetection.Text,
        value: s.ValueDetection.Text
      }
    })
  }
}];

So my result is:

[{
"pdfdata": [
{
"name": "TOTAL",
"value": "53900"
},
{
"name": "INVOICE AND SUPPLY DATE",
"value": "04/04/2022"
}]}]

Which is almost there! :smiley:

But I want the ‘name’ to be the actual data, not “name”:“TOTAL”, i.e. I want to end up with this:

{"TOTAL":"53900"}

I tried:

pdfdata: items[0].json.pdfdata.map(s => { return {
        s.LabelDetection.Text: s.ValueDetection.Text
}})

But that doesn’t work…