maxatwork/form2js — Issue #17: object2array not producing correct array names 100% of the time
Author: boxxxie
Created: 2011-10-13 22:07:16+00:00
State: open

below is taken from the example html code in the dev branch, and my own.
i don't see a difference in my JSON or the example JSON... mine is valid and comes from couchDB.

the example JSON produces the array names properly.
18	Object { name="bar.Addresses[1].Zip", value="98765"}
19	Object { name="bar.Addresses[1].City", value="LA"}
20	Object { name="bar.Addresses[1].Street", value="Under the bridge"}

my JSON produces names that are not correct.
25	Object { name="taxes", value="2"}
26	Object { name="taxes", value="235235"}
27	Object { name="taxes", value=6}

{
"foo":{
"radio":"3",
"name":{
"first":"Foo-First",
"last":"Foo-Last"
},
"selectArray":[ "green", "yellow" ],
"checkboxArray":[ "steak", "chicken" ]
},
"bar":{
"name":{
"first":"Bar-First",
"last":"Bar-Last"
},
"Emails":[
"mail1@example.com",
"mail2@example.com",
"mail3@example.com",
"mail4@example.com",
"mail5@example.com",
"mail6@example.com"
],
"Addresses":[
{"Zip":"12345","City":"NY","Street":"13, Boardwalk"},
{"Zip":"98765","City":"LA","Street":"Under the bridge"}
]
}
}

#from example JSON js2form.html
fieldValues
0	Object { name="foo.radio", value="3"}
1	Object { name="foo.name.first", value="Foo-First"}
2	Object { name="foo.name.last", value="Foo-Last"}
3	Object { name="foo.selectArray[0]", value="green"}
4	Object { name="foo.selectArray[1]", value="yellow"}
5	Object { name="foo.checkboxArray[0]", value="steak"}
6	Object { name="foo.checkboxArray[1]", value="chicken"}
7	Object { name="bar.name.first", value="Bar-First"}
8	Object { name="bar.name.last", value="Bar-Last"}
9	Object { name="bar.Emails[0]", value="mail1@example.com"}
10	Object { name="bar.Emails[1]", value="mail2@example.com"}
11	Object { name="bar.Emails[2]", value="mail3@example.com"}
12	Object { name="bar.Emails[3]", value="mail4@example.com"}
13	Object { name="bar.Emails[4]", value="mail5@example.com"}
14	Object { name="bar.Emails[5]", value="mail6@example.com"}
15	Object { name="bar.Addresses[0].Zip", value="12345"}
16	Object { name="bar.Addresses[0].City", value="NY"}
17	Object { name="bar.Addresses[0].Street", value="13, Boardwalk"}
18	Object { name="bar.Addresses[1].Zip", value="98765"}
19	Object { name="bar.Addresses[1].City", value="LA"}
20	Object { name="bar.Addresses[1].Street", value="Under the bridge"}
-------------------------------------------------------------------------------------------------------------------------------------------
{
"_id": "HB - test",
"_rev": "1-a8cb317e9e4faf750d675843cb91c58e",
"ids": {
"chain": "hero burger",
"chain_min": "HB",
"store": "test store",
"store_min": "test",
"store_num": -1
},
"address": {
"country": "Canada",
"street": [
"adfaf",
"asdfasdf",
"asdf"
],
"city": "Toronto",
"state_prov": "Ontario",
"zip_postal": "M5N L7z",
"phones": [
"23452435",
"23452345",
"23452345"
],
"emails": [
"a@a",
"b@b",
"c@c"
]
},
"contact": "tony",
"operation_hours": [
{
"days": "asdfasfd",
"hours": "asfdasdf"
},
{
"days": "wrtt",
"hours": "rw"
}
],
"taxes": [
{
"taxId": "0",
"number": "23452345",
"percent": 4
},
{
"taxId": "1",
"number": "24352345",
"percent": 5
},
{
"taxId": "2",
"number": "235235",
"percent": 6
}
],
"exemption": {
"amount": "5.99",
"enabled": true
},
"website": "www.heroburger.com"
}
##from my JSON
fieldValues
0	Object { name="_id", value="HB - test"}
1	Object { name="_rev", value="1-a8cb317e9e4faf750d675843cb91c58e"}
2	Object { name="ids.chain", value="hero burger"}
3	Object { name="ids.chain_min", value="HB"}
4	Object { name="ids.store", value="test store"}
5	Object { name="ids.store_min", value="test"}
6	Object { name="ids.store_num", value=-1}
7	Object { name="address.country", value="Canada"}
8	Object { name="address.street", value="adfaf\nasdfasdf\nasdf"}
9	Object { name="address.city", value="Toronto"}
0	Object { name="address.state_prov", value="Ontario"}
11	Object { name="address.zip_postal", value="M5N L7z"}
12	Object { name="address.phones", value="23452435\n23452345\n23452345"}
13	Object { name="address.emails", value="a@a\nb@b\nc@c"}
14	Object { name="contact", value="tony"}
15	Object { name="operation_hours", value="asdfasfd"}
16	Object { name="operation_hours", value="asfdasdf"}
17	Object { name="operation_hours", value="wrtt"}
18	Object { name="operation_hours", value="rw"}
19	Object { name="taxes", value="0"}
20	Object { name="taxes", value="23452345"}
21	Object { name="taxes", value=4}
22	Object { name="taxes", value="1"}
23	Object { name="taxes", value="24352345"}
24	Object { name="taxes", value=5}
25	Object { name="taxes", value="2"}
26	Object { name="taxes", value="235235"}
27	Object { name="taxes", value=6}
28	Object { name="exemption.amount", value="5.99"}
29	Object { name="website", value="www.heroburger.com"}