I have a query string with the following format:
cmd=get-records&limit=100&offset=0&search[0][field]=number&search[0][type]=text&search[0][operator]=contains&search[0][value]=Mike+Jones&search[1][field]=name&search[1][type]=text&search[1][operator]=contains&search[1][value]=Mike+Jones&search[2][field]=role&search[2][type]=text&search[6]&searchLogic=OR
How can I convert this to structured json like the following (or similar):
{
cmd: "...",
limit: "...",
offset: "...",
search: {
0: {
number: "..."
name: "...",
...
}
1: {
...
}
...
},
...
}
I have tried to use urlparse.parse_qs
but it translates the query string to the following:
{
"cmd": ["..."],
"limit": ["..."],
"offset": ["..."],
"search[0][number]": ["..."],
"search[0][name]": ["..."],
"search[1][number]": ["..."].
...
}
The problem with this is the search fields. I want this to be correctly structured. The technologies I am using are as following:
Frontend:
w2ui table that requests data from the backend. Also, as shown in this example, when doing a search it sends a request to the backend to do the search.
Backend:
Django. The post request from w2ui is handled by a view which takes in the query string and acts accordingly.