박찬수

reply, jsonparsing

......@@ -4,4 +4,13 @@ sampleJson = JSON.parse(sampleJson);
console.log(sampleJson);
console.log(sampleJson.response[0].player.name);
\ No newline at end of file
let playerName = sampleJson.response[0].player.name.toString()
console.log(playerName);
console.log(typeof(playerName));
console.log(JSON.stringify(sampleJson.response[0].player.name));
console.log(typeof(JSON.stringify(playerName)));
stringJson = sampleJson.toString();
console.log(sampleJson.toString());
console.log(typeof(stringJson));
\ No newline at end of file
......
......@@ -79,6 +79,9 @@ function Reply(eventObj,replyMsg){
let replyMsgJSON = JSON.parse(replyMsg);
let playerMsg = JSON.parse(replyMsgJSON.response[0].player.name);
let jsonMsg = JSON.parse(replyMsgJSON);
request.post(
{
url: TARGET_URL,
......@@ -90,11 +93,11 @@ function Reply(eventObj,replyMsg){
"messages":[
{
"type":"Name",
"text":replyMsgJSON.response[0].player.name.toString()
"text":playerMsg
},
{
"type":"JSON",
"text":replyMsgJSON.toString()
"text":jsonMsg
}
]
}
......