当前位置: 首页>>代码示例>>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;未经允许,请勿转载。