當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject類代碼示例

本文整理匯總了Java中org.hornetq.utils.json.JSONObject的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject類的具體用法?Java JSONObject怎麽用?Java JSONObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JSONObject類屬於org.hornetq.utils.json包,在下文中一共展示了JSONObject類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AgentClass

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
/**
 * Receives module and ejbName as a single string, separated by the
 * SEPARATOR constant.
 *
 * @param moduleAndEjbName
 * @throws IllegalArgumentException
 */
public AgentClass(String moduleAndEjbName) {
	if (moduleAndEjbName.startsWith("{")) {
		try {
			JSONObject json = new JSONObject(moduleAndEjbName);
			// {"module":"TestAgent","ejbName":"TestAgent","path":""}
			this.module = json.getString("module");
			this.ejbName = json.getString("ejbName");
			this.path = json.has("path") ? json.getString("path") : "";
		} catch (JSONException ex) {
			throw new IllegalArgumentException(ex);
		}
	} else {
		int n = moduleAndEjbName.indexOf(SEPARATOR);
		if (n <= 0 || n >= moduleAndEjbName.length() - 1) {
			throw new IllegalArgumentException("Expected module" + SEPARATOR + "ejbName.");
		}
		this.module = moduleAndEjbName.substring(0, n);
		this.ejbName = moduleAndEjbName.substring(n + 1);
		this.path = "";
	}
}
 
開發者ID:gcvt,項目名稱:siebog,代碼行數:29,代碼來源:AgentClass.java

示例2: toString

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
@Override
public String toString() {
	JSONObject obj = new JSONObject();
	try {
		// TODO Right now, JSONObject will contain only strings, which will need to be parsed
		// manually later on. Implement a better JSON builder.
		obj.put("performative", performative);
		obj.put("sender", sender);
		JSONArray arr = new JSONArray(receivers);
		obj.put("receivers", arr);
		obj.put("replyTo", replyTo);
		obj.put("content", content);
		obj.put("language", language);
		obj.put("encoding", encoding);
		obj.put("ontology", ontology);
		obj.put("protocol", protocol);
		obj.put("conversationId", conversationId);
		obj.put("replyWith", replyWith);
		obj.put("inReplyTo", inReplyTo);
		obj.put("replyBy", replyBy);
		for (Entry<String, Serializable> e : userArgs.entrySet())
			obj.put(USERARG_PREFIX + e.getKey(), e.getValue());
	} catch (JSONException ex) {
	}
	return obj.toString();
}
 
開發者ID:gcvt,項目名稱:siebog,代碼行數:27,代碼來源:ACLMessage.java

示例3: configureParam

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
@POST
@Path("/jobs")
@Consumes("application/json")
@Produces("application/json")
public Response configureParam(String configuration) throws JSONException{
  JSONObject json = (JSONObject) new JSONObject(configuration);
  
  Properties property = new Properties();
  property.put("first", json.getString("FirstName"));
  Gson gson = new GsonBuilder().setPrettyPrinting().create();
  String jsonString = gson.toJson(property);
  
  return Response.status(200).entity(configuration).build();
  
}
 
開發者ID:FITeagle,項目名稱:adapters,代碼行數:16,代碼來源:ACSadapterREST.java

示例4: onRipplePayment

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
@JmsListener(id = "payment_create", destination = "payment_create")
public void onRipplePayment(String message) throws JSONException {
	JSONObject json = new JSONObject();
	json.put("channel", "payment_create");
	json.put("content", message);
	json.put("timestamp", Calendar.getInstance().getTimeInMillis());

	if (clientTemplate != null) {
		clientTemplate.convertAndSend("/topic/payments", json.toString());
	}
}
 
開發者ID:mileschet,項目名稱:ripple-marketmaker,代碼行數:12,代碼來源:ArbitragerChannelListener.java

示例5: onBitstampOfferCreate

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
@JmsListener(id = "bitstamp_offercreate", destination = "bitstamp_offercreate")
public void onBitstampOfferCreate(String message) throws JSONException {
	JSONObject json = new JSONObject();
	json.put("channel", "bitstamp_offercreate");
	json.put("content", message);
	json.put("timestamp", Calendar.getInstance().getTimeInMillis());

	if (clientTemplate != null) {
		clientTemplate.convertAndSend("/topic/payments", json.toString());
	}
}
 
開發者ID:mileschet,項目名稱:ripple-marketmaker,代碼行數:12,代碼來源:ArbitragerChannelListener.java

示例6: AID

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
public AID(String jsonStr) {
	try {
		JSONObject json = new JSONObject(jsonStr);
		name = json.getString("name");
		host = json.has("host") ? json.getString("host") : HOST_NAME;
		str = name + "@" + host;
		if (json.optBoolean("radigost"))
			agClass = RadigostStub.AGENT_CLASS;
		else
			agClass = new AgentClass(json.getString("agClass"));
	} catch (JSONException ex) {
		throw new IllegalArgumentException(ex);
	}
}
 
開發者ID:gcvt,項目名稱:siebog,代碼行數:15,代碼來源:AID.java

示例7: toString

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
@Override
public String toString() {
	JSONObject obj = new JSONObject();
	try {
		obj.put("name", name);
		obj.put("host", host);
		obj.put("agClass", agClass);
		if (agClass.equals(RadigostStub.AGENT_CLASS))
			obj.put("radigost", true); // required by Radigost
		obj.put("str", str);
	} catch (JSONException ex) {
	}
	return obj.toString();
}
 
開發者ID:gcvt,項目名稱:siebog,代碼行數:15,代碼來源:AID.java

示例8: toString

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
@Override
public String toString() {
	JSONObject obj = new JSONObject();
	try {
		obj.put("action", action);
		obj.put("fitness", fitness);
		obj.put("position", position);
	} catch (JSONException ex) {
	}
	return obj.toString();
}
 
開發者ID:gcvt,項目名稱:siebog,代碼行數:12,代碼來源:PsoMessage.java

示例9: valueOf

import org.hornetq.utils.json.JSONObject; //導入依賴的package包/類
public static PsoMessage valueOf(String jsonString) {
	try {
		JSONObject obj = new JSONObject(jsonString);
		return new PsoMessage(obj.getString("action"), obj.getDouble("fitness"), (double[]) obj.get("position"));
	} catch (JSONException ex) {
		ex.printStackTrace();
		return null;
	}
}
 
開發者ID:gcvt,項目名稱:siebog,代碼行數:10,代碼來源:PsoMessage.java


注:本文中的org.hornetq.utils.json.JSONObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。