How to call a specific object with no name inside of an array of array in javascript?

I have a json file called orders and it looks like this

[
    [
        {
            "order_name": "INV-$2b$10$MZfOeZ6mv.nUIBnoIQh/j.VzZu4njdIRaTZ7oL7jxdhRMCxIfiEuu-Honda Brio",
            "created_on": "2021-09-02T08:43:50.902Z",
            "discount": 75000,
            "tax": 50000,
            "total_due": 475000,
            "total_days": 5,
            "payt_trx_number": "TRX-e616u9uhizp",
            "city": "DKI Jakarta",
            "address": "Jl Kelapa Gading",
            "status": "paid",
            "UserId": 6,
            "createdAt": "2021-09-02T08:43:50.902Z",
            "updatedAt": "2021-09-02T08:44:17.909Z",
        }
    ],
    [
        {
            "order_name": "INV-$2b$10$MZfOeZ6mv.nUIBnoIQh/j.VzZu4njdIRaTZ7oL7jxdhRMCxIfiEuu-Honda HRV",
            "created_on": "2021-09-02T05:18:21.753Z",
            "discount": 1050000,
            "tax": 700000,
            "total_due": 6650000,
            "total_days": 14,
            "payt_trx_number": "TRX-bkre8gebgtb",
            "city": "DKI Jakarta",
            "address": "Jl. Palmerah",
            "status": "paid",
            "UserId": 6,
            "createdAt": "2021-09-02T05:18:21.753Z",
            "updatedAt": "2021-09-02T05:18:32.750Z",
        }
    ],
]

How do I call for example the first object?

I can’t figure it out and I’ve stuck here for hours. A way to convert it to a simple array of objects will be appreciated too.

Edit: For anyone wondering why my json file look like this, I messed up during the inserting of my array. I wanted to push some objects into an empty array through a loop, but I got that as a result instead.

Answer

You can use the array flat method like following:

const data = [
  [
    {
      order_name:
        "INV-$2b$10$MZfOeZ6mv.nUIBnoIQh/j.VzZu4njdIRaTZ7oL7jxdhRMCxIfiEuu-Honda Brio",
      created_on: "2021-09-02T08:43:50.902Z",
      discount: 75000,
      tax: 50000,
      total_due: 475000,
      total_days: 5,
      payt_trx_number: "TRX-e616u9uhizp",
      city: "DKI Jakarta",
      address: "Jl Kelapa Gading",
      status: "paid",
      UserId: 6,
      createdAt: "2021-09-02T08:43:50.902Z",
      updatedAt: "2021-09-02T08:44:17.909Z",
    },
  ],
  [
    {
      order_name:
        "INV-$2b$10$MZfOeZ6mv.nUIBnoIQh/j.VzZu4njdIRaTZ7oL7jxdhRMCxIfiEuu-Honda HRV",
      created_on: "2021-09-02T05:18:21.753Z",
      discount: 1050000,
      tax: 700000,
      total_due: 6650000,
      total_days: 14,
      payt_trx_number: "TRX-bkre8gebgtb",
      city: "DKI Jakarta",
      address: "Jl. Palmerah",
      status: "paid",
      UserId: 6,
      createdAt: "2021-09-02T05:18:21.753Z",
      updatedAt: "2021-09-02T05:18:32.750Z",
    },
  ],
];

const flatArray = data.flat();

console.log(flatArray);

Output

[ 
  { 
    "order_name": "INV-$2b$10$MZfOeZ6mv.nUIBnoIQh/j.VzZu4njdIRaTZ7oL7jxdhRMCxIfiEuu-Honda Brio", 
    "created_on": "2021-09-02T08:43:50.902Z", 
    "discount": 75000, 
    "tax": 50000, 
    "total_due": 475000, 
    "total_days": 5, 
    "payt_trx_number": "TRX-e616u9uhizp", 
    "city": "DKI Jakarta", 
    "address": "Jl Kelapa Gading", 
    "status": "paid", 
    "UserId": 6, 
    "createdAt": "2021-09-02T08:43:50.902Z", 
    "updatedAt": "2021-09-02T08:44:17.909Z" 
  }, 
  { 
    "order_name": "INV-$2b$10$MZfOeZ6mv.nUIBnoIQh/j.VzZu4njdIRaTZ7oL7jxdhRMCxIfiEuu-Honda HRV", 
    "created_on": "2021-09-02T05:18:21.753Z", 
    "discount": 1050000, 
    "tax": 700000, 
    "total_due": 6650000, 
    "total_days": 14, 
    "payt_trx_number": "TRX-bkre8gebgtb", 
    "city": "DKI Jakarta", 
    "address": "Jl. Palmerah", 
    "status": "paid", 
    "UserId": 6, 
    "createdAt": "2021-09-02T05:18:21.753Z", 
    "updatedAt": "2021-09-02T05:18:32.750Z" 
  } 
]