我正在开发节点中的Alexa技能,我想知道如何对我的代码进行单元测试.我正在使用亚马逊发布的alexa sdk.
我找到了许多库来实现这一目标,但它们似乎是在alexa sdk可用之前开发的.
提前致谢.
我正在使用PHP创建一个JSON feed echo json_encode($my_array).传递给浏览器的结果字符串应如下所示:
[{"ACC_NUM":"147545","BOOK_DATE":"2011-10-22"},{"ACC_NUM":"147546","BOOK_DATE":"2011-10-22"}]
在Firefox中,如图所示接收json字符串.但是,在webkit浏览器(Safari,Chrome)中,字符串的最后一个字符会被截断.这导致解析错误.
我甚至尝试将feed作为application/json和text/html提供无济于事.
有谁知道发生了什么?我在这里做错了吗?提前致谢.
BACKEND CODE:// $ result包含来自mysql查询的行
if($result) {
$arr = array();
foreach($result as $key => $val) {
$arr[$key] = $val;
}
echo json_encode($arr);
}
Run Code Online (Sandbox Code Playgroud)
这保存在index.php中,我可以在浏览器中查看并显示生成的json feed.
我希望能够从类中获取实例化类的实例的名称.
例:
class MyClass {
getInstanceName() {
// code that figures out the name given to the instance
// instantiating this class
}
}
var inst = new MyClass();
console.log(inst.getInstanceName()); // should log "inst"
Run Code Online (Sandbox Code Playgroud)
我想让它从类中发出一个带有实例名称的事件.我在node.js中这样做