0

I'm currently building some custom filters for a web api. I thought of a custom query string that looks like in the following example:

http://localhost/api/users?filter=

age(min:18,max:45),explvl(atleast:60),classes(types:[golem,tank,dozer])

I didn't want to encode Json to Base64 on the clientside and I find this format much easier to read. Currently I get the filter query parameter back as string. The question I have is how to effectively transform this format to json and backwards if possible.

I'm also open for alternative solutions that achieve the same readability and provide a parser implementation.

9
  • AFAIK JSON wont work as query string because of the quotation marks Commented Jun 24, 2016 at 9:58
  • There's a few types of invalid characters in there, how is this going to work without any form of encoding? Or am I misunderstanding the question? Commented Jun 24, 2016 at 10:00
  • why not just use "post" with normal filter object? (json as is) Commented Jun 24, 2016 at 10:03
  • @Aleksey: Because I have a Pagination mechanism that generates links for the previous and the next page. So I need to pass those filters with some sort of query string. I'm also no fan of using HTTP POST in cases I want to GET Data. Commented Jun 24, 2016 at 10:09
  • @JayMee: I tested the query string and I get it back without problems. Commented Jun 24, 2016 at 10:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.