locked
Parse http querystring variables into a list collection RRS feed

  • Question

  • User1909155429 posted
    responseEnvelope.timestamp=2013-11-10T13%3A08%3A33.748-08%3A00&responseEnvelope.ack=Failure&responseEnvelope.correlationId=85593163d07d7&responseEnvelope.build=7935900&error(0).errorId=520003&error(0).domain=PLATFORM&error(0).subdomain=Application&error(0).severity=Error&error(0).category=Application&error(0).message=Authentication+failed.+API+credentials+are+incorrect.


    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})

     

     

    Sunday, November 10, 2013 4:32 PM

Answers

  • User446859115 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 11, 2013 1:21 PM