i'm having trouble with jQuery.param() adding an empty array key when serializing an object
payload: {
"page":0,
"size":30,
"query":"",
"facets": {
"category": [
"tagName1",
"tagName2"
]
}
}
What i get when i serialize payload is:
page=0&size=30&query=&facets%5Bcategory%5D%5B%5D=tagName1&facets%5Bcategory%5D%5B%5D=tagName2
url decoded:
page=0&size=30&query=&facets[category][]=tagName1&facets[category][]=tagName2
what i'm expecting is (url decoded):
page=0&size=30&query=&facets[category]=tagName1&facets[category]=tagName2
Are my expectations wrong, is this a bug in jquery serialization or is it intended behaviour?
Thanks in advance
[]after arrays are added to make languages like PHP happy IIRC. Passingtruein the second argument to$.param()should fix that problem....&facets=[object object]...trueas the second argument to the function for a "shallow" serialization - but then it will not work correctly with nested objects (also described on the API page).$.param().