0

I am beginner to React Js. I have following input in array

{Transaction Id: "15923826797223102", Transaction Amount: "11", Transaction Currency: "GBP", Requested on: "06/17/2020 08:32:06 UTC", Updated on: "06/17/2020 08:38:31 UTC", …}CC/Check: "GB(United Kingdom)"Data2: "gsr_delay_cashout:19-JUN-20 04:32:06"Payment Id: ""Preference: "pay_instantbank"Requested on: "06/17/2020 08:32:06 UTC"Status: "Closed"Transaction Amount: "11"Transaction Currency: "GBP"Transaction Id: "15923826797223102"Updated on: "06/17/2020 08:38:31 UTC"proto: Object ExportReactCSV.jsx:13 }

I am able to print the array data using following code

let data = JSON.parse(JSON.stringify(csvData))  //csvData is copied above
const list = data.map(name =>{
    console.log(name);
})

Now how to I access element inside the array cause I am not sure if {Transaction Id: "15923826797223102"} can be accessed like

name.Transaction Id

I tried but nothing is getting printed.

Can someone please help me Thank you in advance.

pravin kottawar
  • 153
  • 2
  • 5
  • 16
  • I'm not sure why you need to stringify and re-parse this. In any case, if the question is "how do I access an object property when the key has a space in it", the answer is 'by using bracket notation", e.g., https://stackoverflow.com/q/8317982 – Dave Newton Jun 24 '20 at 17:02

1 Answers1

1

In JS object, key should not be separated by space. In case if it is dynamic key

Then you can try

name['Transaction Id']
Raja Sekar
  • 2,062
  • 16
  • 23