Solved

Split content of return post data, possibly using a dictionary object

Posted on 2012-04-04
2
299 Views
Last Modified: 2012-04-05
I am using ServerXMLHTTP to post to a server and the return post data coming back to me needs to be parsed in to a format I can use. The data is coming back to me like the below :

POST.VALIDATION=ACK&FRONTEND.REDIRECT_URL=https%3A%2F%2Ftest.ctpe.net%2Ffrontend%2FstartFrontend.prc%3Bjsessionid%gg.sbg-vm-fe01&P3.VALIDATION=ACK 

Open in new window


What I want to do is split name / value pairs and, ideally, be able to reference the name value, i.e. be able to test if there is a dictionary item called POST.VALIDATION and what the value is.
0
Comment
Question by:AbeSpain
2 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 37811711
there's no straightforward way to do this, you'll need to split each key/value string, then split each key and value into seperate values.

I'm assuming the "splitter" is the "&" symbol, correct? if so, the code would be:

   data = "POST.VALIDATION=ACK&FRONTEND.REDIRECT_URL=https%3A%2F%2Ftest.ctpe.net%2Ffrontend%2FstartFrontend.prc%3Bjsessionid%gg.sbg-vm-fe01&P3.VALIDATION=ACK"

   Set dictData = Server.CreateObject("Scripting.Dictionary")
   arrData = Split( data, "&" )

   for each keyValuePair in arrData
      arrKeyValuePair = Split( keyValuePair, "=" )      '-- the splitter is now the equals sign
      dictData.Add arrKeyValuePair( 0 ), arrKeyValuePair( 1 )
   next

Open in new window


now all the data is in the dictData dictionary object. For more info, see  http://www.w3schools.com/asp/asp_ref_dictionary.asp

edit: one typo in the code snippet I gave you, now fixed
0
 

Author Comment

by:AbeSpain
ID: 37812295
That's similar to how I did it in the end, I appreciate the reply :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question