Anyone know any project that transforms the query strings into a map, something like rails params.
?pagination.page=23&pagination.quantity=30&filters.brand=dell&filters.color=red
Generates:
{pagination: { page: 23, quantity: 30 }, brand: 'dell', color: 'red' }
specifically, if you’re inside a http handler, request.URL.Query()
Not really, URL.Query() will return this:
{pagination.page: 23, pagination.quantity: 30, filters.brand: 'dell', filters.color: 'red' }
instead of this:
{pagination: { page: 23, quantity: 30 }, brand: 'dell', color: 'red' }
isn’t hard to implement this func, but, i thought had something ready to use
Oh I see. You want it to interpolate name prefixes separated by dots as
representing distinct objects with the same name representing a single
object? You’re right, I don’t know of anything that does that by default.
Shouldn’t be hard to split the keys on dots and insert them into a
map[string]interface{} but yes it would require code.
Sorry,
– Charles
nodir
(Nodir Turakulov)
October 15, 2015, 4:13am
6
FWIW, I think a lib that would unmarshal it to a struct (not map) would be better
matt
(Matt Holt)
October 15, 2015, 5:34am
7
Shameless plug: http://mholt.github.io/binding/
(Library works, but I haven’t touched it in a while.)
system
(system)
Closed
January 13, 2016, 5:34am
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.