本文整理汇总了Java中net.minidev.json.JSONObject类的典型用法代码示例。如果您正苦于以下问题:Java JSONObject类的具体用法?Java JSONObject怎么用?Java JSONObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONObject类属于net.minidev.json包,在下文中一共展示了JSONObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePost
import net.minidev.json.JSONObject; //导入依赖的package包/类
public void handlePost(HttpServletRequest request, HttpServletResponse response, ITicket credentials, JSONObject jsonObject) throws ServletException, IOException {
JSONObject returnMessage = newJSONObject();
JSONObject cargo = (JSONObject)jsonObject.get(ICredentialsMicroformat.CARGO);
String message = "", rtoken="";
String verb = getVerb(jsonObject);
int code = 0;
IResult r;
System.out.println("CondoHandler.handlePost "+verb);
if (verb.equals(ITopicMapMicroformat.PUT_TOPIC)) {
//
} else {
String x = IErrorMessages.BAD_VERB+"-AdminServletPost-"+verb;
environment.logError(x, null);
throw new ServletException(x);
}
returnMessage.put(ICredentialsMicroformat.RESP_TOKEN, rtoken);
returnMessage.put(ICredentialsMicroformat.RESP_MESSAGE, message);
super.sendJSON(returnMessage.toJSONString(), code, response);
returnMessage = null; }
示例2: prepareBugDescriptionForBugCreation
import net.minidev.json.JSONObject; //导入依赖的package包/类
/**
* Prepares the description of bug body. By adding build url, a nice header, a note and
* excaptes html tags, json tags.
*
* @param description
* @return
*/
private String prepareBugDescriptionForBugCreation(String description)
{
description = "*[Automation failed tests]*\n" +
"||Testcase failing|| Parameters||\n" +
description + "\n" +
System.getProperty(AUTO_CREATE_ADDITIONAL_DETAILS,
configuration.getProperty(AUTO_CREATE_ADDITIONAL_DETAILS, "")) + "\n" +
"Build url: " + buildUrl;
description = description + "\n\n\n" + "Note: This bug is created automatically by DolphinNG." +
" Please do not edit summary line of the bug.";
description = StringEscapeUtils.escapeHtml3(description);
description = StringEscapeUtils.escapeHtml4(description);
description = JSONObject.escape(description);
return description;
}
示例3: auditNo
import net.minidev.json.JSONObject; //导入依赖的package包/类
@RequestMapping(value = "/off-audit.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String auditNo(@RequestParam Integer[] ids) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
if (ids == null || ids.length < 1) {
server.put("msg", "Don't do that!The ids is empty!!!");
return output.toJSONString(jsonStyle);
}
try {
appService.updateNoAudit(Arrays.asList(ids));
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} catch (Exception e) {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", "系统错误");
}
return output.toJSONString(jsonStyle);
}
示例4: delRolling
import net.minidev.json.JSONObject; //导入依赖的package包/类
@RequestMapping(value = "/rolling/del.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String delRolling(@RequestParam Integer[] id) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
int rows = rollinfoService.deleteByAppIds(Arrays.asList(id));
boolean del = rows == id.length;
if (del) {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} else {
server.put("code", SvrResult.PART_DATA.getCode());
server.put("msg", SvrResult.PART_DATA.getMsg());
}
} catch (Exception e) {
logger.error("Exception", e);
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
}
return output.toJSONString(jsonStyle);
}
示例5: getInstallPackByType
import net.minidev.json.JSONObject; //导入依赖的package包/类
/**
* 根据marketAppId,cputype(cpu类型),phoneId查询对应的安装包
*
* @param marketAppId
* @param phoneId
* @param cputype
* @return
*/
@RequestMapping(value = { "/install-pack.json", "/cdn/install-pack.json" }, method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String getInstallPackByType(@RequestParam int marketAppId, @RequestParam int phoneId,
@RequestParam int cputype) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
List<BigGamePack> bigGamePack = bigGamePackService.findBigGamePackByParams(marketAppId, phoneId, cputype);
output.put("data", bigGamePack);
server.put("code", OK.getCode());
server.put("msg", OK.getMsg());
} catch (Exception e) {
server.put("code", ERROR.getCode());
server.put("msg", ERROR.getMsg());
logger.error("Exception", e);
}
return output.toJSONString(jsonStyle);
}
示例6: delete
import net.minidev.json.JSONObject; //导入依赖的package包/类
@RequestMapping(value = "/del.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String delete(@RequestParam("id") int id) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
boolean result = service.deleteByIds(Arrays.asList(id));
if (result) {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} else {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
}
} catch (Exception e) {
server.put("code", -1.);
server.put("msg", e.getMessage());
logger.error("Exception:", e);
}
return output.toJSONString();
}
示例7: powerTuiJianChannel
import net.minidev.json.JSONObject; //导入依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/powerchannel/tuijian/{typeId}/{start}/{count}.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String powerTuiJianChannel(@PathVariable int typeId, @PathVariable int start, @PathVariable int count) {
JSONObject res = new JSONObject();
JSONObject server = new JSONObject();
List<App> list = appsService.getPowerChannelTuiJian(typeId, start, count);
if (list == null || list.isEmpty()) {
server.put("code", SvrResult.NO_DATA.getCode());
server.put("msg", SvrResult.NO_DATA.getMsg());
} else {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
// for server developers debugger.
server.put("len", list.size());
}
res.put("data", list);
res.put("result", server);
return res.toJSONString(jsonStyle);
}
示例8: appToManyIntallPackages
import net.minidev.json.JSONObject; //导入依赖的package包/类
/**
* 一个App对应多个安装包
*
* @return
*/
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/cdn/big-game.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String appToManyIntallPackages(@RequestParam(required = true) short catalog,
@RequestParam(required = false) Integer subCatalog) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
List<AppAndBigGamesVo> list = appService.getAppListByCatalog(catalog, subCatalog);
output.put("data", list);
server.put("code", OK.getCode());
server.put("msg", OK.getMsg());
} catch (Exception e) {
server.put("code", ERROR.getCode());
server.put("msg", ERROR.getMsg());
logger.error("Exception", e);
}
return output.toJSONString(jsonStyle);
}
示例9: appByApk
import net.minidev.json.JSONObject; //导入依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/cdn/apk/{pkname}/{signaturesha1}.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String appByApk(@PathVariable String pkname, @PathVariable String signaturesha1) {
ScanApp app = appService.getAppByApk(pkname, signaturesha1);
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
if (app != null) {
output.put("signature", true);
output.put("data", app);
} else {
output.put("signature", false);
ScanApp appByPkname = appService.getAppByPkame(pkname);
output.put("data", appByPkname);
}
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
return output.toJSONString(jsonStyle);
}
示例10: biggameByBrand
import net.minidev.json.JSONObject; //导入依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/cdn/phone-info.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String biggameByBrand(@RequestParam String brand) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
List<PhoneVo> phoneList = phoneInfoService.findPhoneInfoList(brand);
output.put("data", phoneList);
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} catch (Exception e) {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
}
return output.toJSONString(jsonStyle);
}
示例11: getMoTag
import net.minidev.json.JSONObject; //导入依赖的package包/类
@RequestMapping(value = "/get.{id}.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String getMoTag(@PathVariable int id) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
try {
MoTag moTag = service.get(id);
if (moTag != null) {
output.put("data", moTag);
} else {
output.put("data", null);
}
} catch (UnsupportedOperationException e) {
output.put("data", null);
}
return output.toJSONString();
}
示例12: editCatalog
import net.minidev.json.JSONObject; //导入依赖的package包/类
@RequestMapping(value = "/edit-catalog.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String editCatalog(@RequestParam short catalog, @RequestParam int subCatalog, @RequestParam Integer[] ids) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
if (ids == null || ids.length < 1) {
server.put("msg", "Don't do that!The ids is empty!!!");
return output.toJSONString(jsonStyle);
}
boolean edit = appService.updateBatchCatalog(Arrays.asList(ids), catalog, subCatalog);
if (edit) {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} else {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", "数目不对");
}
return output.toJSONString(jsonStyle);
}
示例13: powerTuiJian
import net.minidev.json.JSONObject; //导入依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/power/tuijian/{typeId}/{start}/{count}.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String powerTuiJian(@PathVariable int typeId, @PathVariable int start, @PathVariable int count) {
JSONObject res = new JSONObject();
JSONObject server = new JSONObject();
List<App> list = appsService.getPowerTuiJian(typeId, start, count);
if (list == null || list.isEmpty()) {
server.put("code", SvrResult.NO_DATA.getCode());
server.put("msg", SvrResult.NO_DATA.getMsg());
} else {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
// for server developers debugger.
server.put("len", list.size());
}
res.put("data", list);
res.put("result", server);
return res.toJSONString(jsonStyle);
}
示例14: editCatalog
import net.minidev.json.JSONObject; //导入依赖的package包/类
@RequestMapping(value = "/edit-catalog.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String editCatalog(@RequestParam short catalog, @RequestParam int subCatalog, @RequestParam Integer[] ids,
@RequestParam String subCatalogName) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
if (ids == null || ids.length < 1) {
server.put("msg", "Don't do that!The ids is empty!!!");
return output.toJSONString(jsonStyle);
}
boolean edit = marketAppService.editCatalog(Arrays.asList(ids), catalog, subCatalog, subCatalogName);
if (edit) {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} else {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", "数目不对");
}
return output.toJSONString(jsonStyle);
}
示例15: reset
import net.minidev.json.JSONObject; //导入依赖的package包/类
@RequestMapping(value = "/reset.d", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String reset(HttpServletRequest request) {
long start = System.currentTimeMillis();
logger.info("Accept the quest to reset index!");
searchService.reset();
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
output.put("cost", (System.currentTimeMillis() - start) / 1000 + " s!");
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
return output.toJSONString();
}