2
I am creating a personal account manager. I need to do this with localstorage. Ai am trying to assemble an object with all the debts of a category (in this ex. 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 name of the account (GVT phone, water bill, electricity and etc.) and the value of the account and the due date as elements within that object. But this syntax is wrong according to the site: jsonlint giving this error:
Error: Parse error on line 3: ... "arrayDebits": ! ["GVT": ! "value" -------------------------------------------------------- Expecting 'STRING', '}', got '['
I’m missing where?
Vlw, more because I need the keys after [ and before closing the ]?
– CarlosM
@Carlosm
[ ]
that is to sayarray
. In the example above you have an array, with 1 object inside. I assume that later you will have N right objects, or is it just 1? If it’s only 1 you don’t need to[ ]
you can take and leave only the object.– Sergio
I want each input of the array to be a different object... It can be like this?
{ "nameCategory": "Bradesco", "arrayDebits": [{ "GVT": { "value": "220,00", "PaymentDate": "10/10/2010" } }, { "Agua": { "value": "150,00", "PaymentDate": "15/15/2015" } } ] }
– CarlosM
@Carlosm yes, it can. I thought that
GVT
andAgua
would be the same, but if they are not like that it works. But in this case, I would do something like this: in view of havingAgua
andGVT
outside the internal object would:{"nameCategory":"Bradesco","arrayDebits":[{"type":"GVT","value":"220,00","PaymentDate":"10/10/2010"},{"type":"Agua","value":"150,00","PaymentDate":"15/15/2015"}]}
– Sergio
@Carlosm like this is much easier to use after
– Sergio
show, I’ll use it like this... vlw!
– CarlosM