Trouble parsing JSON in Classic ASP

After receiving a JSON Response from a remote server, everything looks good. I discovered an helpful script for parsing the JSON data and extracting the necessary values.

When attempting to pass the variable into JSON.parse(), I encountered an error which has been detailed in my code comments.

If anyone can help me identify where I might have gone wrong, I would greatly appreciate it. Despite trying multiple variations, I haven't had any luck so far. Thank you for taking the time to read this.

<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
<!--#include file="json2.asp"-->
<%

  url = "https://www.beds24.com/api/json/getBookings"
  propKey = Request.QueryString("propkey")

  jsonrequest = "{""authentication"": { ""apiKey"": ""XXXXXX"", ""propKey"": """&propKey&""" }, ""includeInvoice"": false, ""includeInfoItems"": false}"
  
'SEND JSON TO SERVER
 Dim oXMLHttp
 Set oXMLHttp=Server.Createobject("MSXML2.ServerXMLHTTP.6.0")
 oXMLHttp.open "POST", url,false
 oXMLHttp.setRequestHeader "Content-Type", "application/json"
 oXMLHttp.send jsonrequest

'GET JSON RESPONSE BACK FROM SERVER
    jsonstring = oXMLHttp.responseText

'Here's the raw response from the Server
response.write(jsonstring&"<br><br><br>")

...

An error is being displayed in the browser:

Microsoft JScript compilation error '800a03ee'

Expected ')'

/API/beds24/GetBookings/json2.asp, line 765

The content of json2.asp is included below:

<script language="Javascript" runat="server">

// JavaScript code goes here...

</script>

Answer №1

Thanks to @SearchAndResQ, the issue has been successfully resolved with their comment.

To solve this problem, you can utilize the server response directly without any alterations. Simply include the following code snippet and comment out all the replace lines in your existing code:

for each bkg in booking : if bkg.get("roomId")<>"" Then : Response.Write("roomId: "& bkg.get("roomId") & "<br>"): end if : next 

[Note that you can substitute the : in the provided code with newlines since multiline code is not fully supported in comments] – SearchAndResQ

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implementing a Fixed Position for a Single Record in Extjs 4.2 Sortable Grid

Is there a way to allow users to sort by any column in a simple grid with sorting enabled, while ensuring that a specific record is always displayed at the last position (based on its ID)? I am working with ExtJS 4.2.2. ...

Missing Ajax Functionality in Laravel Application

The code snippet below was created by me... <script> $('#spielAuswahl').on('change', function(e){ console.log(e); var spielID = e.target.value; //ajax $get.('/spieler?spielID=' + sp ...

What steps should be taken once the idToken in Firebase has expired?

My code is utilizing the onAuthStateChanged function: this.unregisterAuthObserver = firebase.auth().onAuthStateChanged(user => { if (user) { user.getIdToken(true).then((idToken) => { console.log(user) ... }); } After the idT ...

Assign the filename to the corresponding label upon file upload

I've customized my file uploader input field by hiding it and using a styled label as the clickable element for uploading files. You can check out the implementation on this jsFiddle. To update the label text with the actual filename once a file is s ...

Tips for displaying the message "{"POWER":"ON"}" within the else if statement (this.responseText == ({"POWER":"ON"})) {

Hey everyone, I'm trying to adjust the color of a button on my webpage based on the response I receive from this.responseText. I understand the JSON response, but for some reason, I can't seem to incorporate it into my code. If anyone could lend ...

Detecting collisions between two squares in an HTML5 canvas

class Snake { constructor() { this.x = 400; this.y = 400; this.width = 25; this.height = 25; } draw() { ctx.fillRect(this.x, this.y, this.width, this.height); } } let snake = new Snake(); class ...

Click on each item within the v-for loop to gather relevant information, and subsequently iterate through the collected data

Within a v-for loop, I have implemented a button that, when clicked, retrieves specific data. The objective is to display this data below or in place of the clicked button. <div v-for="(item, index) in items" :key="index"> <button @click="fetch ...

Creating a progress bar for file uploads without using jQuery

We're currently seeking a way to implement a file upload progress bar feature without relying on ajax or jQuery. Unfortunately, we haven't come across any helpful tutorials through our Google searches. Below is the basic code snippet we have so ...

Is there a way to find strings in R that share at least one common word?

Data Frame 1 Sample: NAME; CITY; STATE; SURNAME; Maria Antonia Sousa A X Antonia Sousa Josep Oliveira Carlos A X Oliveira Carlos Jose Mario Augusto Farias B Y Augusto Farias Andre Go ...

Filtering MYSQL query results based on the result of an alias (AS)

Here is a MySQL query that I'm working with: SELECT t1.*, (SELECT count(*) FROM tb_pt t2 WHERE t2.id_provinsi = t1.id_provinsi && nama_pt LIKE '%$nama%' && status_pt = 1 ) As jumlah FROM tb_provinsi t1 WHERE st ...

What is causing my button to act in this way?

Initially, the website redirects to an undefined URL and then to test.com. I am looking for a way to implement a redirection sequence from to and finally to <head> <script type="text/javascript"> <!-- function popup(url ...

Summarize the array of objects and find the average value for each distinct object name

I'm facing a challenge with an array structure: const originalArray = [ { name: "a", value: 1 }, { name: "a", value: 2 }, { name: "a", value: 3 }, { name: "b", ...

JavaScript loop to target a specific item

My goal is to animate the correct div under each navigation item, rather than all of them with the "navItemUnder" class. You can see exactly what I mean by hovering over a navigation item in this codePen. I am looking for a solution to target only one lin ...

The POST request to the localhost API endpoint resulted in a 404 Not Found error

Whenever I try to send a POST request to "/api/auth/signup" in my JavaScript application, I keep getting a 404 Not Found error. My goal is to create a MERN application for a Modern Real Estate Marketplace. This is the code snippet causing the is ...

Tips for inheriting and overriding controller methods in AngularJS with Java as the base language:

I have a simple controller and I want to create a new controller that is very similar to it, but without copying too much code. angular.module('test').controller('parentController', parentController); parentController.$inject = [' ...

Ace Code Editor: Turn off highlighted line beneath cursor

I am currently utilizing the Ace editor and would like to remove the shadowed line where the cursor is located. Here's an example Even after experimenting with different themes provided by Ace Mode Creator, the shadowed line still persists. Any sug ...

Issue with Material Table not refreshing data after mutation occurs

Whenever a user includes more details, a mutation is performed in the database to add the new information. Subsequently, the local state is updated to include the new data in the lead. Although my mutation and state update successfully, there seems to be ...

Continuously refresh the if/else statement

I'm currently facing an issue with my jQuery code regarding a responsive navigation bar. I am trying to add a class called 'mobile' to the navigation bar when it reaches close to the logo. Below is the snippet of my code: function respon ...

In the realm of asp.net mvc, JSON remains a mysterious and undefined

When working with ASP.NET MVC 3, I have encountered an issue regarding JSON in my AJAX calls. The application runs smoothly on my development machine when using Visual Studio. However, after publishing the same application and trying to access it through a ...

creating a while loop in node.js

In C#, the following code would be used: double progress = 0; while (progress < 100) { var result = await PerformAsync(); progress = result.Progress; await Task.Delay(); } This concise piece of code spans just 7 lines. Now, how can we ...