URL query string convention for multiple sort

后端 未结 3 481
醉酒成梦
醉酒成梦 2021-02-01 06:59

I have a RESTful web application that supports multiple sort fields on a collection of items. Is there a common convention for encoding these sort fields into the query string o

3条回答
  •  面向向阳花
    2021-02-01 07:25

    What about a fully PHP compliant version like this one:

    http://myapp.com/books?sort[0][name]=author&sort[0][dir]=asc&sort[1][name]=datepublished&sort[1][dir]=desc&count=12
    

    A bit longer but much convinient and as I've said, compliant with PHP. ASP.NET might have implemented support for this format also.

    This will create an array, sort, directly where each element of sort has a name and dir property.

提交回复
热议问题