-
Feb 20th, 2012, 09:21 PM
#1
Spring & JQuery Nested Object Formatting $.post
I was digging into something interesting I saw...JQuery likes to format parameters using [] instead of .
Has anyone written a filter/request wrapper/something to handle this?
Take this example, you want to post the following to the server.
{"name":"test","address":[{"city":"one","state":"a"},{"city":"two","state":" b"}]}
Send it as JSON, life is good. Do $.post(...), not as much. It comes across as:
name=test&address[0][city]=one&address[0][state]=a&address[1][city]=two&address[1][state]=b
But Spring (the BeanWrapper) wants:
name=test&address[0].city=one&address[0].state=a&address[1].city=two&address[1].state=b
I wrote up a quick filter to inject a custom RequestWrapper around the request that does some magic to convert the parameter names. Seems to work, but is there a better way to do this? Or something in Spring that handles it?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules