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


Java JsonObject.toString方法代碼示例

本文整理匯總了Java中com.eclipsesource.json.JsonObject.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonObject.toString方法的具體用法?Java JsonObject.toString怎麽用?Java JsonObject.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.eclipsesource.json.JsonObject的用法示例。


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

示例1: sendIdentityMessageTo

import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public void sendIdentityMessageTo(MessagingIdentity contactIdentity)
	throws InterruptedException, IOException, WalletCallException
{
	// Only a limited set of values is sent over the wire, due tr the limit of 330
	// characters. // TODO: use protocol versions with larger messages
	MessagingIdentity ownIdentity = this.messagingStorage.getOwnIdentity();
	JsonObject innerIDObject = new JsonObject();
	innerIDObject.set("nickname",           ownIdentity.getNickname());
	innerIDObject.set("firstname",          ownIdentity.getFirstname());
	innerIDObject.set("surname",            ownIdentity.getSurname());
	innerIDObject.set("senderidaddress",    ownIdentity.getSenderidaddress());
	innerIDObject.set("sendreceiveaddress", ownIdentity.getSendreceiveaddress());
	JsonObject outerObject = new JsonObject();
	outerObject.set("zenmessagingidentity", innerIDObject);
	String identityString = outerObject.toString();
	
	// Check and send the messaging identity as a message
	if (identityString.length() <= 330) // Protocol V1 restriction
	{
		this.sendMessage(identityString, contactIdentity);
	} else
	{
		JOptionPane.showMessageDialog(
			this.parentFrame, 
			"The size of your messaging identity is unfortunately too large to be sent\n" +
			"as a message. Your contact will have to import your messaging identity\n" +
			"manaully from a json file...", 
			"Messaging identity size is too large!", JOptionPane.ERROR_MESSAGE);
		return;
	}
}
 
開發者ID:ZencashOfficial,項目名稱:zencash-swing-wallet-ui,代碼行數:32,代碼來源:MessagingPanel.java

示例2: getRawTransaction

import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public synchronized String getRawTransaction(String txID)
	throws WalletCallException, IOException, InterruptedException
{
	JsonObject jsonTransaction = this.executeCommandAndGetJsonObject(
		"gettransaction", wrapStringParameter(txID));

	return jsonTransaction.toString(WriterConfig.PRETTY_PRINT);
}
 
開發者ID:ZencashOfficial,項目名稱:zencash-swing-wallet-ui,代碼行數:9,代碼來源:ZCashClientCaller.java

示例3: toJson

import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public String toJson() {
	JsonObject result = Json.object();
	if (!isEmpty()) {
		JsonObject errors = Json.object();
		if (general != null) {
			errors.add("general", general);
		}
		for (Entry<String, String> cur : entrySet()) {
			errors.add(cur.getKey(), cur.getValue());
		}
		result.add("errors", errors);
	}
	return result.toString();
}
 
開發者ID:dernasherbrezon,項目名稱:r2cloud,代碼行數:15,代碼來源:ValidationResult.java

示例4: addMessagingGroup

import com.eclipsesource.json.JsonObject; //導入方法依賴的package包/類
public void addMessagingGroup()
{
	try
	{
		CreateGroupDialog cgd = new CreateGroupDialog(
			this, this.parentFrame, this.messagingStorage, this.errorReporter, this.clientCaller);
		cgd.setVisible(true);
		
		if (!cgd.isOKPressed())
		{
			return;
		}
		
		// So a group is created - we need to ask the user if he wishes to send an identity message 
		MessagingIdentity createdGroup = cgd.getCreatedGroup();
		
		int sendIDChoice = JOptionPane.showConfirmDialog(
			this.parentFrame, 
			"Do you wish to send a limited sub-set of your contact details to group\n" + 
			createdGroup.getDiplayString() + "\n" +
			"This will allow other group members to know your messaging identity.",
			"Send contact details?", JOptionPane.YES_NO_OPTION);
			
		// TODO: code duplication with import
		if (sendIDChoice == JOptionPane.YES_OPTION)
		{
			// Only a limited set of values is sent over the wire, due tr the limit of 330
			// characters. // TODO: use protocol versions with larger messages
			MessagingIdentity ownIdentity = this.messagingStorage.getOwnIdentity();
			JsonObject innerIDObject = new JsonObject();
			innerIDObject.set("nickname",           ownIdentity.getNickname());
			innerIDObject.set("firstname",          ownIdentity.getFirstname());
			innerIDObject.set("surname",            ownIdentity.getSurname());
			innerIDObject.set("senderidaddress",    ownIdentity.getSenderidaddress());
			innerIDObject.set("sendreceiveaddress", ownIdentity.getSendreceiveaddress());
			JsonObject outerObject = new JsonObject();
			outerObject.set("zenmessagingidentity", innerIDObject);
			String identityString = outerObject.toString();
			
			// Check and send the messaging identity as a message
			if (identityString.length() <= 330) // Protocol V1 restriction
			{
				this.sendMessage(identityString, createdGroup);
			} else
			{
				JOptionPane.showMessageDialog(
					this.parentFrame, 
					"The size of your messaging identity is unfortunately too large to be sent\n" +
					"as a message.", 
					"Messaging identity size is too large!", JOptionPane.ERROR_MESSAGE);
				return;
			}
		}
	} catch (Exception ex)
	{
		this.errorReporter.reportError(ex, false);
	}
}
 
開發者ID:ZencashOfficial,項目名稱:zencash-swing-wallet-ui,代碼行數:59,代碼來源:MessagingPanel.java


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