iron-ajax icon indicating copy to clipboard operation
iron-ajax copied to clipboard

nested objects in params not encoded properly

Open malthusyau opened this issue 9 years ago • 2 comments

Setting iron-ajax's params property to a nested object in javascript: params = {foo: 'foo', bar: { baz: 1}};

The nested object doesn't get encoded in the query string: ?foo=foo&bar=%5Bobject%20Object%5D

malthusyau avatar Feb 23 '16 20:02 malthusyau

How would you expect the object to be encoded?

In the absence of a standard for form-encoding nested objects my preference would be that we provide an easy-to-override method for encoding params so that folks can use inheritance (upcoming feature in polymer core: https://github.com/Polymer/polymer/issues/3345) to encode this in whatever syntax their particular server expects.

rictic avatar Feb 29 '16 23:02 rictic

@rictic Is there any known workaround? I have been trying to stringify the param myself as described in #39 but then the whole json string gets encoded.

Here is an example :

http://localhost:9078/?0=%7B&1=%22&2=j&3=s&4=o&5=n&6=%22&7=%3A&8=%7B&9=%22&…16=e&117=n&118=-&119=J&120=T&121=j&122=t&123=B&124=g&125=1&126=%22&127=%7D

It is blocking me because I am trying to have part of the json payload dynamic, and the API I play against only supports json params.

EDIT: Note that I have tried the workaround described here, but I end up with the same issue as #39 when trying because my object is several levels deep.

Thanks

jlengrand avatar Jul 10 '17 19:07 jlengrand