Вопрос

Basically I want the query string ?foo%5B%5Bbar%5D%5D=whizbang to give me a result that looks like this:

{ 'foo' : { '[bar]' : 'whizbang' } }

I'm using rails at the moment, and instead of '[bar]' i'm getting 'bar' (ie the [] stripped out). I tried this in PHP for a comparison, which has '[bar' (rstripped of ]) this seems wrong to me also.

I am trying to work out if this is a bug that i need to log for rails.

I'm using JQuery.ajax to send an object that looks like that to rails.

Это было полезно?

Решение

If you're trying to formulate the params in javascript and have access to jquery, you can use $.param:

$.param({ 'foo' : { '[bar]' : 'whizbang' } })
// => foo%5B%5Bbar%5D%5D=whizbang
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top