i return the above string to page and would like to parse the variables into a more convenient form for easy access.
more appropriately, i would like to further parse on error(n). string variables and return each related substring and add to another list object. like such
I'm not clear as to where you want to preform the parsing. Are you looking to preform this function at the client (anotherwords in javascript) or on the server? If on the server are you posting the data or using a GET? Do the names in the name-value-pair
change from post to post or are they always the same list?
In general I'd split the request string into an array of name-value-pairs (NVP) using the string method split which is available in Javascript, c# or VB. Then step through the resulting array building whatever datastructure you require. I usuall use the
standard string parsing techniques centered around indexing off the equal sign.
If you know before hand the NVP elements and are using a GET, and you're processing on the server side you can skip the string splitting step and just use the QueryString["element"] name format.
Member
288 Points
886 Posts
Parse http querystring variables into a list collection
Nov 10, 2013 04:32 PM|peterthegreat|LINK
Hi,
i return the above string to page and would like to parse the variables into a more convenient form for easy access.
more appropriately, i would like to further parse on error(n). string variables and return each related substring and add to another list object. like such
error(0), ({ errorId,category,severity,message})
error(1),({ errorId,category,severity,message})
Member
534 Points
207 Posts
Re: Parse http querystring variables into a list collection
Nov 11, 2013 01:21 PM|elbilo|LINK
I'm not clear as to where you want to preform the parsing. Are you looking to preform this function at the client (anotherwords in javascript) or on the server? If on the server are you posting the data or using a GET? Do the names in the name-value-pair change from post to post or are they always the same list?
In general I'd split the request string into an array of name-value-pairs (NVP) using the string method split which is available in Javascript, c# or VB. Then step through the resulting array building whatever datastructure you require. I usuall use the standard string parsing techniques centered around indexing off the equal sign.
If you know before hand the NVP elements and are using a GET, and you're processing on the server side you can skip the string splitting step and just use the QueryString["element"] name format.