本文整理汇总了Java中net.minidev.json.JSONObject.toJSONString方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.toJSONString方法的具体用法?Java JSONObject.toJSONString怎么用?Java JSONObject.toJSONString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minidev.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.toJSONString方法的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: initIndex
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/inittrietree/{typeId}.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String initIndex(@PathVariable String typeId) {
logger.debug("#initIndex");
int appTypeId = Integer.parseInt(typeId);
JSONObject res = new JSONObject();
JSONObject server = new JSONObject();
try {
this.searchService.initTrieDict(appTypeId);
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} catch (Exception e) {
logger.error("Exception", e);
server.put("code", SvrResult.NO_DATA.getCode());
server.put("msg", SvrResult.NO_DATA.getMsg());
}
res.put("result", server);
return res.toJSONString(jsonStyle);
}
示例3: powerTuiJianTopicApps
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/power/tuijian/topic/apps/{topicid}/{start}/{count}.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String powerTuiJianTopicApps(@PathVariable int topicid, @PathVariable int start, @PathVariable int count) {
JSONObject res = new JSONObject();
JSONObject server = new JSONObject();
List<App> list = appsService.getPowerTuiJianTopicApps(topicid, 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);
}
示例4: sort
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/sort.json", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@ResponseBody
public String sort(@RequestParam Integer[] ids, @RequestParam Integer[] ranks) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
boolean result = moTagRelationshipService.updateMoAppAndTagSort(ids, ranks);
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 (UnsupportedOperationException e) {
server.put("code", -1.);
server.put("msg", e.getMessage());
}
return output.toJSONString();
}
示例5: editCatalogConvertor
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = { "/edit.json", "add.json" }, produces = "application/json;charset=UTF-8")
@ResponseBody
public String editCatalogConvertor(Catalog entity) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
if (entity.getId() == null) {
server.put("msg", "参数编号错误!");
return output.toJSONString(jsonStyle);
}
boolean result = service.saveOrUpdate(entity);
if (result) {
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);
}
示例6: 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);
}
示例7: 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();
}
示例8: editCatalogConvertor
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/catalogconvertor/edit.json", produces = "application/json;charset=UTF-8")
@ResponseBody
public String editCatalogConvertor(CatalogConvertor entity) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
if (entity.getId() == null || entity.getId() < 1) {
server.put("msg", "参数编号错误!");
return output.toJSONString(jsonStyle);
}
if (validateModels(entity)) {
boolean result = service.saveOrUpdate(entity);
if (result) {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} else {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", "数目不对");
}
} else {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", "数据错误,请确认数据完整性!");
}
return output.toJSONString(jsonStyle);
}
示例9: 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);
}
示例10: 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);
}
示例11: search
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/search.json", produces = "application/json;charset=UTF-8")
@ResponseBody
public String search(HttpServletRequest request, @RequestParam(required = false) Short type,
@RequestParam(required = false) Short picType, @RequestParam(required = false) Boolean hidden,
@RequestParam int page, @RequestParam int rows, @RequestParam(required = false) String keywords,
@RequestParam(required = false) String sort, @RequestParam(required = false) String order) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
List<MoMixFeatured> list = service.search(type, picType, hidden, keywords, page, rows, sort, order);
Long count = service.countForSearching(type, picType, hidden, keywords);
output.put("result", server);
output.put("rows", list);
output.put("total", count == null ? 0 : count);
return output.toJSONString();
} catch (Exception e) {
logger.error("Exception", e);
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
}
return output.toJSONString(jsonStyle);
}
示例12: updateLogo
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/rolling/upd-logo.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String updateLogo(MultipartHttpServletRequest multipartReq, @RequestParam int id) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
appService.updateLogo(multipartReq, id);
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
} catch (Exception e) {
logger.error("Exception", e);
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
}
return output.toJSONString(jsonStyle);
}
示例13: 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);
}
示例14: tagsByAppId
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/tags/{appId}.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String tagsByAppId(@PathVariable int appId) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
List<MoAppAndTag> list = moTagRelationshipService.getMoAppAndTagsByAppId(appId);
output.put("data", list);
} catch (Exception e) {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
}
return output.toJSONString();
}
示例15: search
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/search.json", produces = "application/json;charset=UTF-8")
@ResponseBody
public String search(@RequestParam int page, @RequestParam int rows, @RequestParam(required = false) String q,
@RequestParam(required = false) String sort, @RequestParam(required = false) String order) {
List<Keyword> list = keywordService.search(page, rows, q, sort, order);
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
output.put("rows", list);
output.put("total", keywordService.countForSearching(q));
return output.toJSONString();
}