我收到了来自网络服务器的回复:
{
"errors": [ ],
"info": [ ],
"isSuccessful": true,
"responseHeaders":
{
"Connection": "close",
"Content-Length": "159",
"Content-Type": "text\/html",
"Date": "Sat, 20 Feb 2016 11:15:35 GMT",
"Server": "Apache",
"X-Powered-By": "PHP\/5.2.17" },
"responseTime": 705,
"statusCode": 200,
"statusReason": "OK",
"text": "True \n<!-- Hosting24 Analytics Code -->\n<script type=\"text\/javascript\" src=\"http:\/\/stats.hosting24.com\/count.php\"><\/script>\n<!-- End Of Analytics Code -->",
"totalTime": 706,
"warnings": [ ]
}
我的代码段检索真值:
var response = WL.Server.invokeHttp(input);
// Extract value from the response.
var type = typeof response;
if ("object" == type) {
if (true == response["isSuccessful"]) {
// Drill down into the response object.
var results = response["results"];
var result = results[0];
var val = result["text"];
// Return JSON object
return val;
}
else {
// Returning null. Web request was not successful.
return null;
}
}
如何向下钻取并仅从 adapter-impl.js 中的"text": "True"
中提取值?
我可以请一些吗?感谢。
答案 0 :(得分:0)
你能尝试这种方式。还有一件事,看你想要返回json object
。所以,必须写json格式或转换json。
var response= WL.Server.invokeHttp(input);
if (response.statusCode==200 && response.isSuccessful==true){
var val =response.text
return {
data:val
}
}
else{
return null
}