本文整理汇总了Java中net.minidev.json.JSONObject.put方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.put方法的具体用法?Java JSONObject.put怎么用?Java JSONObject.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minidev.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: topicSearch
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/topic-search.json", produces = "application/json;charset=UTF-8")
@ResponseBody
public String topicSearch(@RequestParam(required = false) Integer tagId, @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();
Short tagType = (short) TagType.TOPIC.getVal();
List<ViewTagApps> list = tagRelationshipService.searchAppAndTag(tagId, null, tagType, page, rows, keywords,
sort, order);
Long count = tagRelationshipService.countForSearchingAppAndTag(tagId, null, tagType, keywords);
JSONObject server = new JSONObject();
output.put("result", server);
output.put("rows", list);
output.put("total", count == null ? 0 : count);
return output.toJSONString();
}
示例2: saveTagApp
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/save.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String saveTagApp(MoAppAndTag mTagApp) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
if (mTagApp.getId() > 0) {
moTagRelationshipService.updateMoAppAndTag(mTagApp);
} else {
moTagRelationshipService.saveMoAppAndTag(mTagApp);
}
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();
}
示例3: 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);
}
示例4: getCoreQuery
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
String getCoreQuery(String verb, String userId, String userIP, String sToken) throws ServletException {
try {
JSONObject json = new JSONObject();
json.put(ICredentialsMicroformat.VERB, verb);
json.put(ICredentialsMicroformat.USER_ID, userId);
json.put(ICredentialsMicroformat.SESSION_TOKEN, sToken);
json.put(ICredentialsMicroformat.USER_IP, userIP);
String result = json.toJSONString();
result = URLEncoder.encode(result, "UTF-8");
json = null;
return result;
} catch (Exception e) {
environment.logError(e.getMessage(), e);
throw new ServletException(e);
}
}
示例5: search
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/search.d", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String search(@RequestParam String keyword, @RequestParam String typeId) {
keyword = keyword.trim();
int appTypeId = Integer.parseInt(typeId);
List<App> list = searchService.search(appTypeId, keyword);
JSONObject res = new JSONObject();
JSONObject server = new JSONObject();
if (list == null || list.size() == 0) {
List<String> suggestions = searchService.spellChecker(appTypeId, keyword);
server.put("code", SvrResult.NO_DATA.getCode());
server.put("msg", SvrResult.NO_DATA.getMsg());
server.put("len", 0);
res.put("keywordTips", suggestions);
} else {
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
server.put("len", list.size());
}
res.put("data", list);
res.put("result", server);
return res.toJSONString(jsonStyle);
}
示例6: setRecommand
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/rolling/set-recommand.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String setRecommand(@RequestParam Integer[] id) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
int rows = rollinfoService.updateRecommand(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);
}
示例7: updatePWD
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
/**
* 普通用户修改密码
*
* @param keywords
* @param request
* @param model
* @return
* @throws IOException
*/
@RequestMapping(value = "/update-pwd.d", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public @ResponseBody
String updatePWD(@RequestParam("o_pwd") String oldPwd, @RequestParam("n_pwd") String newPwd, HttpSession session,
Model model, HttpServletResponse resp) throws IOException {
User u = (User) session.getAttribute("user");
JSONObject json = new JSONObject();
if (u == null) {
json.put("status", false);
json.put("msg", "登陆超时,请重新登陆。");
return json.toJSONString();
}
if (!u.getPassword().equals(PWDHelper.escape(oldPwd))) {
json.put("status", false);
json.put("msg", "原密码不对");
return json.toJSONString();
} else {
newPwd = PWDHelper.escape(newPwd);
service.updatePwd(u.getId(), newPwd);
json.put("status", true);
json.put("msg", "更新成功");
return json.toJSONString();
}
}
示例8: saveTagApp
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/save.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String saveTagApp(AppAndTag tagApp) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
if (tagApp.getId() > 0) {
tagRelationshipService.updateAppAndTag(tagApp);
} else {
tagRelationshipService.saveAppAndTag(tagApp);
}
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();
}
示例9: searchBox
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/cdn/s/quickTips.json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
public String searchBox(@RequestParam String q) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
String[] tips = null;
try {
tips = quickTipsService.quickTips(q);
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());
logger.error("Exception", e);
}
if (tips != null && tips.length > 0) {
output.put("data", tips);
} else {
output.put("data", emptyArray);
}
return output.toJSONString(jsonStyle);
}
示例10: health
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/health.d", produces = "application/json;charset=UTF-8")
@ResponseBody
public String health() {
JSONObject server = new JSONObject();
server.put("msg", "It's running...");
return server.toJSONString();
}
示例11: smsUserChannelUpdate
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
/**
* 发送短信
*
* @return
*/
@RequestMapping(value = "/sms.d", method = RequestMethod.POST)
public @ResponseBody
String smsUserChannelUpdate(@RequestParam(required = false) Integer[] ids) {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
try {
List<MonUserChannelApp> list = service.queryList(Arrays.asList(ids));
if (list == null || list.size() < 1) {
server.put("code", SvrResult.ERROR.getCode());
server.put("msg", SvrResult.ERROR.getMsg());
}
boolean result = service.updateSmsUserChannelUpdate(list);
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();
}
示例12: all
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@Cacheable(exp = defaultCacheTime)
@RequestMapping(value = "/all.json", produces = "application/json;charset=UTF-8")
@ResponseBody
public String all() {
JSONObject output = new JSONObject();
JSONObject server = new JSONObject();
output.put("result", server);
List<CatalogInfo> list = service.listCatalogInfo();
output.put("rows", list);
server.put("code", SvrResult.OK.getCode());
server.put("msg", SvrResult.OK.getMsg());
return output.toJSONString(jsonStyle);
}
示例13: handlePost
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
public void handlePost(HttpServletRequest request, HttpServletResponse response, ITicket credentials, JSONObject jsonObject) throws ServletException, IOException {
JSONObject returnMessage = newJSONObject();
System.out.println("AUTHPOST "+jsonObject.toJSONString());
String message = "", rtoken="";
String verb = getVerb(jsonObject);
int code = 0;
//We have nothing to do here
returnMessage.put(ICredentialsMicroformat.RESP_TOKEN, rtoken);
returnMessage.put(ICredentialsMicroformat.RESP_MESSAGE, message);
super.sendJSON(returnMessage.toJSONString(), code, response);
returnMessage = null;
}
示例14: getMarkets
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/catalogconvertor/market.list.json", produces = "application/json;charset=UTF-8")
@ResponseBody
public String getMarkets() {
JSONObject jsonData = new JSONObject();
List<Market> makets = marketSecurityService.findMarkets();
Map<Integer, String> mapList = new HashMap<Integer, String>();
for (Market market : makets) {
mapList.put(market.getId(), market.getMarketName());
}
jsonData.put("data", mapList);
return jsonData.toJSONString();
}
示例15: 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();
}