📜  从 http 页面请求中提取 JSON - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:48.509000             🧑  作者: Mango

代码示例1
//get the previous http response and eval it
var resp_ = context.variableManager.getValue("EntryResponse");
if (resp_ == null) {
        context.fail("Variable 'EntryResponse' not found");
}
logger.debug("EntryResponse="+resp_);
var resp = eval("("+resp_+")")

//then used resp as real json
logger.debug("Logged User Id="+resp.data.id);

// Inject a value in a runtime variable
context.variableManager.setValue("UserName", resp.data.id);