Solved

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

Posted on 2012-04-04
2
290 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 32

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now