Hi, I need to extract the field values of a GET query of type:
http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value&fields[2]=f2value
Is there a way to handle this apart from HttpRequest.QueryFields?
Regards,

Mailing lists / lazarus / 2016-04
9 messages · 3 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi, I need to extract the field values of a GET query of type:
http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value&fields[2]=f2value
Is there a way to handle this apart from HttpRequest.QueryFields?
Regards,
Yes.
Supposing you have an object called "TQuery" with the published property "Fields", you can do it easily with the "TBrookParser" object. Take a look at this demo:
I've been using the "Fields" property as "TStringList", but you can use any list type, just creating a list adapter for that.
Feel free to use the Brook community
<https://plus.google.com/u/0/communities/101133820055678331036> too! :-)
Regards,
-- Leonardo M. Ram? http://leonardorame.blogspot.com
Hi, I need to extract the field values of a GET query of type:…
What other way would you like ? What is not good about this way ?
Michael.
El 15/04/16 a las 16:22, Michael Van Canneyt escribi?:
It works pefectly por param=value&..., but I don't know how to parse array type values.
example: ?filters[0]['filter']=name&filters[0]['value']=john
Regards,
What is the problem ? Everything before a = is the name ?
So:
Name:=Request.QueryFields.values['filters[0][''filter'']'];
Value:=Request.QueryFields.values['filters[0][''value'']'];It doesn't automatically convert them to arrays, obviously. For that you need to know how the array (in this case double array) is encoded.
Microsoft uses() in it's query names, like in:
?filters(0,'filter')=name&filters(0,'value')=john
I see no need to provide routines for this.
Michael.
El 15/04/16 a las 16:22, Michael Van Canneyt escribi?: It works pefectly por…
On Fri, Apr 15, 2016 at 4:25 PM, Leonardo M. Ram?
wrote:
[...]
It works pefectly por param=value&..., but I don't know how to parse array type values. example: ?filters[0]['filter']=name&filters[0]['value']=john
This filter can be easily parser if you send it as:
?filters[0].filter=name&filters[0].value=john
The parser can populate a class structure like:
=== code ===
TYourObject = class
published
property filter: string ...;
property value: string ...;
end;
TFilters = class(TFPGMapObject<TYourObject>)
end;=== /code ===
On Fri, Apr 15, 2016 at 4:33 PM, silvioprog wrote: [...]
This filter can be easily parser ...
I meant: "This filter can be easily parsed ... ".
On Fri, Apr 15, 2016 at 4:25 PM, Leonardo M. Ram? [...] This filter can be easily parser…
El 15/04/16 a las 16:33, silvioprog escribi?:
Sorry, nevermind. I've found a way to configure KendoUi Grid to send queries as POST using JSON, so, problem solved.
On Fri, Apr 15, 2016 at 4:37 PM, Leonardo M. Ram?
wrote:
[...]
Sorry, nevermind. I've found a way to configure KendoUi Grid to send queries as POST using JSON, so, problem solved.
Awesome. :-)
tip: you can use jQuery $.param before sent the JSON filter to FCL-web/Brook, and decode it with HTTPDecode()+FPJson in the server. :-)