在阅读以下性能测试时,我注意到作者使用过$(0)和$(1).这样做的目的是什么?
http://jsperf.com/scriptjunkie-premature-3
var $a = $(0);
function fn_1() {
var $a = $(this);
if ($a.attr("rel") == "foo") {
$a.addClass("foo");
}
else {
$a.addClass("other");
}
}
function fn_2() {
$a.context = $a[0] = this; // fake the collection object
if ($a.attr("rel") == "foo") {
$a.addClass("foo");
}
else {
$a.addClass("other");
}
}
Run Code Online (Sandbox Code Playgroud) 我正在开发python和GAE,
当我尝试使用ProtoRPC进行Web服务时,我找不到让我的请求在消息中包含json格式数据的方法.像这样的例子:
请求格式:
{"owner_id":"some id","jsondata":[{"name":"peter","dob":"1911-1-1","aaa":"sth str","xxx":sth int}, {"name":...}, ...]}'
Run Code Online (Sandbox Code Playgroud)
蟒蛇:
class some_function_name(messages.Message):
owner_id = messages.StringField(1, required=True)
jsondata = messages.StringField(2, required=True) #is there a json field instead of StringField?
Run Code Online (Sandbox Code Playgroud)
还有其他建议吗?