我从工作灯适配器调用后收到了响应。
{"text": "{\n \"responseCode\" : \"00\",\n \"responseMsg\" : null,\n \"buildFromAccountsMap\" : {\n \"1000071000005844 D\" : \"1000071000005844\",\n \"1000791000030636 D\" : \"1000791000030636\",\n \"1001911000036935 D\" : \"1001911000036935\",\n \"1002021000029411 D\" : \"1002021000029411\",\n \"1005071000029666 D\" : \"1005071000029666\",\n \"1005071000033139 D\" : \"1005071000033139\",\n \"1005071000037533 D\" : \"1005071000037533\",\n \"1005071000038605 D\" : \"1005071000038605\",\n \"1005071000045298 D\" : \"1005071000045298\",\n \"1005071000045517 D\" : \"1005071000045517\",\n \"1005071000046989 D\" : \"1005071000046989\",\n \"1005071000056183 D\" : \"1005071000056183\",\n \"1005491000019560 D\" : \"1005491000019560\",\n \"2000071000163308 S\" : \"2000071000163308\",\n \"2000071000163361 S\" : \"2000071000163361\"\n }}
我的工作灯适配器
function buildFromAccounts(userId) {
path = "xxxxxxxxxxxxxxxxx";
var input = {
method : 'post',
returnedContentType : 'plain',
path : path,
body:{
contentType:'application/json; charset=UTF-8',
content:
JSON.stringify({
"userId": userId.toString()
})
}
};
return WL.Server.invokeHttp(input);
}
问题是,如何在worklight中将这种纯格式转换为json格式?
最佳答案
您为returnedContentType
设置了什么? JSON 还是普通格式?
编辑:因为您返回的是普通...
尝试类似以下内容:var obj = JSON.parse(response.text)
关于javascript - JSON - 如何将普通格式转换为json格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24324629/