Java Code Examples for org.json.JSONWriter#key()

The following examples show how to use org.json.JSONWriter#key() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LedgerHeader.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
public void toJSONWriter(JSONWriter writer) {
    writer.key("ledger_index");
    writer.value(sequence.toJSON());
    writer.key("total_coins");
    writer.value(totalXRP.toString(10));
    writer.key("parent_hash");
    writer.value(previousLedger.toJSON());
    writer.key("transaction_hash");
    writer.value(transactionHash.toJSON());
    writer.key("account_hash");
    writer.value(stateHash.toJSON());
    writer.key("close_time");
    writer.value(closeTime.toJSON());
    writer.key("parent_close_time");
    writer.value(parentCloseTime.toJSON());
    writer.key("close_time_resolution");
    writer.value(closeResolution.toJSON());
    writer.key("close_flags");
    writer.value(closeFlags.toJSON());
}
 
Example 2
Source File: LedgerHeader.java    From ripple-lib-java with ISC License 6 votes vote down vote up
public void toJSONWriter(JSONWriter writer) {
    writer.key("ledger_index");
    writer.value(sequence.toJSON());
    writer.key("total_coins");
    writer.value(totalXRP.toString(10));
    writer.key("parent_hash");
    writer.value(previousLedger.toJSON());
    writer.key("transaction_hash");
    writer.value(transactionHash.toJSON());
    writer.key("account_hash");
    writer.value(stateHash.toJSON());
    writer.key("close_time");
    writer.value(closeTime.toJSON());
    writer.key("parent_close_time");
    writer.value(parentCloseTime.toJSON());
    writer.key("close_time_resolution");
    writer.value(closeResolution.toJSON());
    writer.key("close_flags");
    writer.value(closeFlags.toJSON());
}
 
Example 3
Source File: LedgerHeader.java    From jingtum-lib-java with MIT License 5 votes vote down vote up
public void toJSONWriter(JSONWriter writer) {
    writer.key("ledger_index");
    writer.value(sequence.toJSON());
    writer.key("total_coins");
    writer.value(totalXRP.toString(10));
    writer.key("parent_hash");
    writer.value(previousLedger.toJSON());
    writer.key("transaction_hash");
    writer.value(transactionHash.toJSON());
    writer.key("account_hash");
    writer.value(stateHash.toJSON());
    writer.key("close_time");
    writer.value(closeTime.toJSON());
    writer.key("parent_close_time");
    writer.value(parentCloseTime.toJSON());
    writer.key("close_time_resolution");
    writer.value(closeResolution.toJSON());
    writer.key("close_flags");
    writer.value(closeFlags.toJSON());
}
 
Example 4
Source File: Record.java    From sndml3 with MIT License 5 votes vote down vote up
public String toJSON() {
	StringWriter writer = new StringWriter();
	JSONWriter json = new JSONWriter(writer);
	json.object();
	for (String name : this.getFieldNames()) {
		String value = this.getValue(name);
		if (value != null && value.length() > 0) {
			json.key(name);
			json.value(value);				
		}
	}
	json.endObject();
	return writer.toString();
}
 
Example 5
Source File: AbstractProjectChoiceProvider.java    From onedev with MIT License 4 votes vote down vote up
@Override
public void toJson(Project choice, JSONWriter writer) throws JSONException {
	writer.key("id").value(choice.getId());
	writer.key("name");
	writer.value(HtmlEscape.escapeHtml5(choice.getName()));
}
 
Example 6
Source File: Json.java    From onedev with MIT License 3 votes vote down vote up
/**
    * Writes a key/value pair into the {@code writer} if the value is not {@code null}
    * 
    * @param writer
    *            json writer
    * @param key
    *            key
    * @param value
    *            value
    * @throws JSONException
    */
   public static void writeObject(JSONWriter writer, String key, Object value) throws JSONException {
if (value != null) {
    writer.key(key);
    writer.value(value);
}
   }