本文整理汇总了Java中com.google.appengine.labs.repackaged.org.json.JSONObject类的典型用法代码示例。如果您正苦于以下问题:Java JSONObject类的具体用法?Java JSONObject怎么用?Java JSONObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONObject类属于com.google.appengine.labs.repackaged.org.json包,在下文中一共展示了JSONObject类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parsePnoSettings
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
private static HashMap<String, String> parsePnoSettings(String settingsString) {
if (!RiseUtils.strIsNullOrEmpty(settingsString)) {
try {
JSONArray settingsArray = new JSONArray(settingsString);
HashMap<String, String> settings = new HashMap<String, String>();
for (int i = 0; i < settingsArray.length(); i++) {
JSONObject setting = settingsArray.getJSONObject(i);
String name = setting.getString("name");
String value = setting.optString("value", null);
settings.put(name, value);
}
return settings;
} catch (JSONException e) {
e.printStackTrace();
}
}
return null;
}
开发者ID:Rise-Vision,项目名称:rva,代码行数:24,代码来源:CompanyServiceImpl.java
示例2: serializeToJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
@Override
public JSONObject serializeToJSON() throws JSONException {
JSONObject root = new JSONObject();
root.put("variable", this.variable);
root.put("code", this.code.getId());
root.put("datatype", this.type == null ? "" : this.type.toString()
.toLowerCase());
root.put("required", this.required);
root.put("datatype_description", this.type_description);
root.put("order", this.order);
root.put("description", this.description);
JSONArray values = new JSONArray();
if (listValues != null) {
for (Entry<String, String> e : listValues.entrySet()) {
JSONObject j = new JSONObject();
j.put("key", e.getKey());
j.put("name", e.getValue());
values.put(j);
}
}
root.put("values", values);
return root;
}
开发者ID:hasier,项目名称:voxpopuli,代码行数:24,代码来源:Attribute.java
示例3: fromJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
/**
* Creates a new instance of {@link SendRequest} based on the values derived from the specified {@code json}.
*
* @param json
* the {@code JSONObject} from which the details are to be derived
* @return The {@link SendRequest} derived from {@code json}.
* @throws IllegalArgumentException
* If any of the required derived values are invalid.
* @throws JSONException
* If {@code json} is malformed.
* @throws NullPointerException
* If {@code json} is {@code null}.
*/
public static SendRequest fromJSON(JSONObject json) throws JSONException {
SendRequest request = new SendRequest();
request.setApiKey(json.getString("apiKey"));
request.setHtml(json.optString("html", null));
request.setSender(Contact.fromJSON(json.getJSONObject("sender")));
request.setSubject(json.getString("subject"));
request.setText(json.optString("text", null));
JSONArray recipients = json.getJSONArray("recipients");
for (int i = 0; i < recipients.length(); i++) {
request.addRecipient(Contact.fromJSON(recipients.getJSONObject(i)));
}
return request;
}
开发者ID:neocotic,项目名称:mail-manager,代码行数:29,代码来源:SendRequest.java
示例4: toJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
/**
* Creates a {@code JSONObject} based on this {@link SendRequest}.
*
* @return The derived {@code JSONObject}.
* @throws JSONException
* If this {@link SendRequest} is malformed.
*/
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put("apiKey", apiKey);
json.putOpt("html", html);
json.put("sender", sender.toJSON());
json.put("subject", subject);
json.putOpt("text", text);
JSONArray array = new JSONArray();
for (Contact recipient : recipients) {
array.put(recipient.toJSON());
}
json.put("recipients", array);
return json;
}
开发者ID:neocotic,项目名称:mail-manager,代码行数:24,代码来源:SendRequest.java
示例5: updateContestInfo
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
private static void updateContestInfo(Map<Test, Pair<Integer, Integer>> testsGraded, List<Test> tiesBroken, Entity contestInfo, StringBuilder errorLog) throws JSONException {
SimpleDateFormat isoFormat = new SimpleDateFormat("hh:mm:ss a EEEE MMMM d, yyyy zzzz");
isoFormat.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
contestInfo.setProperty("updated", isoFormat.format(new Date()).toString());
List<String> testsGradedList = new ArrayList<String>();
for (Test test : testsGraded.keySet()) {
if (testsGraded.get(test).x > 0 && tiesBroken.contains(test)) {
testsGradedList.add(test.toString());
}
}
contestInfo.setProperty("testsGraded", testsGradedList);
JSONObject testsGradedJSON = new JSONObject();
for (Entry<Test, Pair<Integer, Integer>> entry : testsGraded.entrySet()) {
JSONArray numTests = new JSONArray().put(entry.getValue().x).put(entry.getValue().y);
testsGradedJSON.put(entry.getKey().toString(), numTests);
}
contestInfo.setProperty("testsGradedNums", new Text(testsGradedJSON.toString()));
contestInfo.setProperty("errorLog", new Text(errorLog.toString()));
datastore.put(contestInfo);
}
开发者ID:sushain97,项目名称:contestManagement,代码行数:26,代码来源:Main.java
示例6: savePnoSettings
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
public void savePnoSettings(CompanyInfo company) throws ServiceFailedException {
String url = createCompanyResource(company.getId());
String settingsString = "";
try {
JSONArray settingsArray = new JSONArray();
// iterate through list to add elements.
for (String key : company.getSettings().keySet()){
JSONObject setting = new JSONObject();
setting.put("name", key);
setting.put("value", company.getSettings().get(key));
settingsArray.put(setting);
}
settingsString = settingsArray.toString();
} catch (JSONException e) {
e.printStackTrace();
throw new ServiceFailedException();
}
Form form = new Form();
form.add(CompanyAttribute.SETTINGS, settingsString);
put(url, form);
}
开发者ID:Rise-Vision,项目名称:rva,代码行数:29,代码来源:CompanyServiceImpl.java
示例7: serializeToJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
@Override
public JSONObject serializeToJSON() throws JSONException {
JSONObject root = new JSONObject();
root.put("service_code", this.code.getId());
root.put("service_name", this.name);
root.put("description", this.description);
root.put("metadata", this.hasMetadata);
root.put("type", this.type.toString().toLowerCase());
root.put("keywords", Joiner.on(", ").join(keywords));
root.put("group", this.group);
return root;
}
开发者ID:hasier,项目名称:voxpopuli,代码行数:13,代码来源:Service.java
示例8: getJSONError
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
public static JSONObject getJSONError(int code, String message)
throws JSONException {
JSONObject j = new JSONObject();
j.put("code", code);
j.put("description", message);
return j;
}
开发者ID:hasier,项目名称:voxpopuli,代码行数:8,代码来源:JSONUtils.java
示例9: pushUpdates
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
public static void pushUpdates(List<User> users, String message, String url) {
ChannelService channelService = ChannelServiceFactory
.getChannelService();
try {
JSONObject json = new JSONObject();
json.put("message", message);
json.put("link", url);
for (User user : users) {
channelService.sendMessage(new ChannelMessage(KeyFactory
.keyToString(user.getKey()), json.toString()));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
开发者ID:hasier,项目名称:voxpopuli,代码行数:16,代码来源:Utils.java
示例10: serializeToJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
@Override
public JSONObject serializeToJSON() throws JSONException {
JSONObject root = new JSONObject();
root.put("service_code", this.serviceCode.getId());
JSONArray attrs = new JSONArray();
for (Attribute a : attributes) {
attrs.put(a.serializeToJSON());
}
root.put("attributes", attrs);
return root;
}
开发者ID:hasier,项目名称:voxpopuli,代码行数:13,代码来源:ServiceDefinition.java
示例11: serializeToJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
@Override
public JSONObject serializeToJSON() throws JSONException {
JSONObject root = new JSONObject();
root.put("service_request_id", this.id);
root.put("status", this.status.toString().toLowerCase());
root.put("status_notes", this.statusNotes);
root.put("service_name", this.service.getName());
root.put("service_code", this.service.getCode().getId());
root.put("description", this.description);
root.put("agency_responsible", this.agency);
root.put("service_notice", this.serviceNotice);
root.put("requested_datetime",
Utils.W3C_DATE_FORMAT.format(this.requestDate));
root.put("updated_datetime",
Utils.W3C_DATE_FORMAT.format(this.updateDate));
if (this.expectedDate != null) {
root.put("expected_datetime",
Utils.W3C_DATE_FORMAT.format(this.expectedDate));
}
root.put("address", this.address);
root.put("address_id", this.addressId);
root.put("zipcode", this.postalCode);
root.put("lat", this.lat);
root.put("long", this.lon);
String url = "";
if (this.media != null) {
url = "/media?key=" + this.media.getKeyString();
}
root.put("media_url", url);
return root;
}
开发者ID:hasier,项目名称:voxpopuli,代码行数:32,代码来源:ServiceRequest.java
示例12: toJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
/**
* Creates a {@code JSONObject} based on this {@link Application}.
*
* @return The derived {@code JSONObject}.
* @throws JSONException
* If this {@link Application} is malformed.
*/
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put("apiKey", apiKey);
json.put("name", name);
return json;
}
开发者ID:neocotic,项目名称:mail-manager,代码行数:15,代码来源:Application.java
示例13: toJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
/**
* Creates a {@code JSONObject} based on this {@link Contact}.
*
* @return The derived {@code JSONObject}.
* @throws JSONException
* If this {@link Contact} is malformed.
*/
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put("email", email);
json.putOpt("name", name);
return json;
}
开发者ID:neocotic,项目名称:mail-manager,代码行数:15,代码来源:Contact.java
示例14: doGet
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
String url = "";
String urlLinktext = "Login";
String user = "";
String email = (String) req.getSession().getAttribute("login");
JSONObject json = new JSONObject();
List<String> jray = new ArrayList<String>();
JSONObject json2 = new JSONObject();
List<String> jray2 = new ArrayList<String>();
Comparator<HistoryModel> tmComparator = new Comparator<HistoryModel>() {
@Override
public int compare(HistoryModel o1, HistoryModel o2) {
return o2.getDate().compareTo(o1.getDate());
}
};
if (email != null) {
try {
EntityManager em = EMFService.get().createEntityManager();
UsuariosDAOImpl udao = UsuariosDAOImpl.getInstance();
TransactionDAOImpl tdao = TransactionDAOImpl.getInstance();
usuario = udao.readUserByEmail(em, email);
List<HistoryModel> umh = usuario.getHistories();
double finalValue = 0.0;
Collections.sort(umh, tmComparator);
for (HistoryModel hm : umh) {
finalValue = Math.round(hm.getAmount() * 100.0) / 100.0;
json.put("quantity", finalValue + this.getCurrencySymbol(hm.getCoin()));
json.put("type", hm.getType());
json.put("date", hm.getDate().toLocaleString().replace("-", " "));
json.put("user", usuario.getEmail());
jray.add(json.toString());
}
List<TransactionModel> tml = tdao.readTransactions(em);
for (TransactionModel tm: tml) {
if(tm.getFriendId() != null) {
if(tm.getFriendId().longValue() == usuario.getId().longValue()){
json2.put("friend", udao.readUserByCardN(em, tm.getCardN()).getEmail());
json2.put("coinD", tm.getDCoin());
json2.put("quantityS", tm.getAmount());
json2.put("coinS", tm.getSCoin());
json2.put("quantityD", getConverted(tm.getSCoin(), tm.getDCoin(), tm.getAmount(), times[2]));
json2.put("id", tm.getId());
jray2.add(json2.toString());
}
}
}
em.close();
String jsonText = jray.toString();
String jsonText2 = jray2.toString();
req.getSession().setAttribute("history", jsonText);
req.getSession().setAttribute("friends", jsonText2);
} catch (JSONException e) {
e.printStackTrace();
}
user = usuario.getName();
url = "/logout";
urlLinktext = "Logout";
}
req.getSession().setAttribute("user", user);
req.getSession().setAttribute("url", url);
req.getSession().setAttribute("urlLinktext", urlLinktext);
req.getSession().setAttribute("currencies", currencies);
RequestDispatcher view = req.getRequestDispatcher("transaction.jsp");
view.forward(req, resp);
}
开发者ID:enriquecs,项目名称:Currexify-Server,代码行数:74,代码来源:TransactionServlet.java
示例15: doGet
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// get Access to Mirror Api
Mirror mirror = getMirror(req);
// get TimeLine
Timeline timeline = mirror.timeline();
try {
JSONObject json = new JSONObject(retrieveIPool());
JSONArray arr = json.getJSONArray("documents");
JSONArray media = new JSONArray();
String title = null;
String content = null;
String URL = null;
for (int i = 0; i < arr.length(); i++) {
title = arr.getJSONObject(i).getString("title");
// maybe for future use but for tts needs to be stripped from html tags
//content = arr.getJSONObject(i).getString("content");
media = arr.getJSONObject(i).getJSONArray("contentReferences");
}
if (media.length()!=0){
for (int i = 0; i < media.length(); i++) {
URL = media.getJSONObject(i).getString("externalUrl");
}
}
String html = "<article class=\"photo\">\n <img src=\""+URL+"\" width=\"100%\" height=\"100%\">\n <div class=\"overlay-gradient-tall-dark\"/>\n <section>\n <p class=\"text-auto-size\">"+title+"</p>\n </section>\n</article>";
// create a timeline item
TimelineItem timelineItem = new TimelineItem()
//.setSpeakableText(content)
.setSpeakableText(title)
.setHtml(html)
.setDisplayTime(new DateTime(new Date()))
.setNotification(new NotificationConfig().setLevel("Default"));
// add menu items with built-in actions
List<MenuItem> menuItemList = new ArrayList<MenuItem>();
menuItemList.add(new MenuItem().setAction("DELETE"));
menuItemList.add(new MenuItem().setAction("READ_ALOUD"));
menuItemList.add(new MenuItem().setAction("TOGGLE_PINNED"));
timelineItem.setMenuItems(menuItemList);
// insert the crad into the timeline
timeline.insert(timelineItem).execute();
//print out results on the web browser
resp.setContentType("text/html; charset=utf-8");
//resp.setCharacterEncoding("UTF-8");
resp.getWriter().println(
"<html><head><meta http-equiv=\"refresh\" content=\"3;url=/index.html\"></head> "
+ "<body>"+html+"</body></html>");
} catch (JSONException e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
String error = errors.toString();
//resp.setContentType("text/html; charset=utf-8");
resp.setCharacterEncoding("UTF-8");
resp.getWriter().println(
"<html><head><meta http-equiv=\"refresh\" content=\"3;url=/index.html\"></head> "
+ "<body>JSON Exception " +error+" </body></html>");
}
}
开发者ID:ipool,项目名称:GlassPool,代码行数:70,代码来源:IpoolAPIClient.java
示例16: fromJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
/**
* Creates a new instance of {@link Application} based on the values derived from the specified {@code json}.
*
* @param json
* the {@code JSONObject} from which the details are to be derived
* @return The {@link Application} derived from {@code json}.
* @throws IllegalArgumentException
* If any of the required derived values are invalid.
* @throws JSONException
* If {@code json} is malformed.
* @throws NullPointerException
* If {@code json} is {@code null}.
*/
public static Application fromJSON(JSONObject json) throws JSONException {
return new Application(json.getString("apiKey"), json.getString("name"));
}
开发者ID:neocotic,项目名称:mail-manager,代码行数:17,代码来源:Application.java
示例17: fromJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
/**
* Creates a new instance of {@link Contact} based on the values derived from the specified {@code json}.
*
* @param json
* the {@code JSONObject} from which the details are to be derived
* @return The {@link Contact} derived from {@code json}.
* @throws IllegalArgumentException
* If the derived email address is empty.
* @throws JSONException
* If {@code json} is malformed.
* @throws NullPointerException
* If {@code json} is {@code null}.
*/
public static Contact fromJSON(JSONObject json) throws JSONException {
return new Contact(json.getString("email"), json.optString("name", null));
}
开发者ID:neocotic,项目名称:mail-manager,代码行数:17,代码来源:Contact.java
示例18: serializeToJSON
import com.google.appengine.labs.repackaged.org.json.JSONObject; //导入依赖的package包/类
public JSONObject serializeToJSON() throws JSONException;
开发者ID:hasier,项目名称:voxpopuli,代码行数:2,代码来源:DataSerializable.java
注:本文中的com.google.appengine.labs.repackaged.org.json.JSONObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论