I'm in the starting phases of designing an API. I'd like it to be Restful and comply with what's commonly considered best practices.
One of my resources need to accept several query string parameters. Here's an example:
{
"pick_up": {
"datetime": "20200301T1400",
"location": {
"lat": 40.68231,
"lng": -73.52935
}
},
"drop_off": {
"datetime": "20200401T1400",
"location": {
"lat": 40.68231,
"lng": -73.52935
}
}
}
The above is how I would probably represent the parameters as a JSON. That could be converted to a query string:
pick_up%5Bdatetime%5D=20200301T1400&pick_up%5Blocation%5D%5Blat%5D=40.68231&pick_up%5Blocation%5D%5Blng%5D=-73.52935&drop_off%5Bdatetime%5D=20200401T1400&drop_off%5Blocation%5D%5Blat%5D=40.68231&drop_off%5Blocation%5D%5Blng%5D=-73.52935
That will work, but it'll look ugly. Maybe something like this would look prettier:
pick_up_datetime=20200301T1400&pick_up_location_lat=40.68231&pick_up_location_lng=-73.52935 ....
Aside from the subjective "pretty"factor, are there any benefits of one over the other? Perhaps in terms of generally accepted best practice, security, RESTful design, etc?