Array inside an object, what is the correct syntax?

2

I'm creating a personal account manager. I need to do this with localstorage. Here I am trying to assemble an object with all the debits of a category (in this case the category is bradesco).

{
"nameCategory": "Bradesco",
"arrayDebits": {
    ["GVT": {
        "value": "220,00",
        "PaymentDate": "10/10/2010"
    }, "Agua": {
        "value": "150,00",
        "PaymentDate": "15/15/2015"
    }]
}

Each debit needs to be an object, I thought of putting the name of the object as the account name (GVT phone, water bill, light etc.) and the value of the account and the expiration date as elements within that object. But this syntax is wrong on the site: jsonlint giving this error:

  

Error: Parse error on line 3:   ... "arrayDebits": {["GVT": {"value"   ---------------------- ^   Expecting 'STRING', '}', got '['

I'm missing out where?

    
asked by anonymous 01.05.2017 / 19:53

1 answer

2

You are using wrong syntax, with [] inside {} , what you want is instead, since arrayDebits is an array with objects inside:

[{obj1}, {obj2}, etc...]

that would look like this:

{
  "nameCategory": "Bradesco",
  "arrayDebits": [
    {
      "GVT": {
        "value": "220,00",
        "PaymentDate": "10/10/2010"
      },
      "Agua": {
        "value": "150,00",
        "PaymentDate": "15/15/2015"
      }
    }
  ]
}
    
01.05.2017 / 19:57