将PHP(JSON)转换为ASP代码

时间:2021-12-19 01:45:44

Can someone convert below code to ASP format?

有人可以将代码转换为ASP格式吗?

<?php

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

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

while I was testing cross domain restriction workaround, this code works fine with PHP server (of course) , thing is I'd like to implement this under ASP environment. I tried here http://www.me-u.com/php-asp/hosting/asp.php though. Thanks in advance.

当我测试跨域限制解决方法时,这个代码与PHP服务器(当然)工作正常,我想在ASP环境下实现这个。我试过http://www.me-u.com/php-asp/hosting/asp.php。提前致谢。

1 个解决方案

#1


Like, once?

<%
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 string concatenation business can be avoided if you are going to print out all of it anyway (e.g. there is no further use for it being in a variable):

如果要打印出所有的字符串连接业务,可以避免整个字符串连接业务(例如,它没有进一步用于变量):

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

#1


Like, once?

<%
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 string concatenation business can be avoided if you are going to print out all of it anyway (e.g. there is no further use for it being in a variable):

如果要打印出所有的字符串连接业务,可以避免整个字符串连接业务(例如,它没有进一步用于变量):

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