Convert PHP (JSON) to ASP Code

Can someone convert below code to ASP format?

<?php

$data = '
[
  {
    "A": "test",
    "B": "test",
    "C": "test"
  },
  {
    "A": "test",
    "B": "test",
    "C": "test"
  }
]
';

print($_GET['callback'] .'('. $data .')');

      

While I was testing a workaround for cross domain restriction, this code works fine with a PHP server (of course), the point is, I would like to implement this in an ASP environment. I've tried here http://www.me-u.com/php-asp/hosting/asp.php . Thanks in advance.

0


a source to share


1 answer


How, one day?

<%
Dim data 

''// VBScript Strings cannot span multiple lines, we must use
''// concatenation ("&") and line continuation markers ("_")
''// (also, double quotes need to be escaped by *double* double quotes)
data = "" & _
  "[" & _
  "  {" & _
  "    ""A"": ""test""," & vbCrLf & _
  "    ""B"": ""test""," & vbCrLf & _
  "    ""C"": ""test"""  & vbCrLf & _
  "  }," & vbCrLf & _
  "  {" & vbCrLf & _
  "    ""A"": ""test""," & vbCrLf & _
  "    ""B"": ""test""," & vbCrLf & _
  "    ""C"": ""test""" & vbCrLf & _
  "  }" & vbCrLf & _
  "]"

Response.Write Request.QueryString("callback") & "(" & data & ")"
%>

      



The whole business of string concatenation can be avoided if you print it all out anyway (for example, no more use for a variable):

<%
Response.Write Request.QueryString("callback") & "("
%>
[
  {
    "A": "test",
    "B": "test",
    "C": "test"
  },
  {
    "A": "test",
    "B": "test",
    "C": "test"
  }
]
<%
Response.Write ")"
%>

      

+2


a source







All Articles