We help IT Professionals succeed at work.
Get Started

Pass SQL to JSON. Page is in classic ASP and using Jquery

Aleks
Aleks asked
on
640 Views
Last Modified: 2017-04-09
I have a page (ASP classic) which has a recordset with data.

recordset name:  rs_contact
field1:  FName
field2: LName
field3: email

This is the first time I will be doing this so a good explanation would be very much appreciated.
I need to pass this data to a JSON format so that I can the post it to an URL (to be used by an API)

The page is in classic ASP. The data I need to pass is in the format below. This considering I only got one result in my recordset and the values returned are:

FirstNm = 'Aleks'
LastNm = 'Demo'
email = 'support@domain.com'

Those values somehow need to be turned into this JSON
We have to consider there may be more than one result from the recordset, another set of values would be:

Alma
Doe
alma@domain.com

etc.

This is the JSON file example I have to create:

{
  "first_name": "Aleks",
  "last_name": "Demo",
  "email_addresses": [
    {
      "email_address": "support@domain.com"
    }
  ]
}

Open in new window


Once this is created I need to post the data to an URL that is also stored in a recordset.

The URL will require a token as parameter, so I need to pass 2 parameters, the first part is the URL and the second is the token.

something like: https://<%=url("value")%>?token?<%=token("value")%>

Example:

http://myurl/contacts/add?token=ada23-4234-234234-2

Open in new window


We can break this down in those two parts. One is taking the recordset info and converting it into JSON.  And the second part is posting this JSON to the URL.
Comment
Watch Question
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2017
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE