I’m trying to pass lists and maps as GET parameters, and I’m wondering if there are particular conventions (or preferably, libraries) with which I can do so. Specifically, I’d like to pass lists and maps.
Lists are relatively easy, given that we properly URL-encode our delimiter (in this case, a comma):
/images/kittens?furColors=brown,black
Maps are more complicated. I’ve seen something like this:
/images/kittens?properties[furColors]=brown,black&properties[eyeColors]=blue
I’ve also seen something like this:
/images/kittens?properties=furColors%3Dbrown,black;eyeColors%3Dblue;
Is there a nice standard somewhere that I can follow? Also, I happen to be using Java and Spring (for reasons out of my control), and I’d like to be able to use a library to handle this, preferably one whose strings Spring can parse.
You could pass JSON arrays or objects. Why not use an existing, well established standard rather than inventing your own?
Or perhaps protobuf would be a better fit.
I’d rather do anything that develop and maintain my own. I’m lazy.
Watch out for the 1024 byte limit on GET request strings. You can only be so complex.