本文整理汇总了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 = "";
}
}
示例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();
}
示例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();
}
示例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());
}
}
示例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());
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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;
}
}