org.json.JSONWriter Java Examples
The following examples show how to use
org.json.JSONWriter.
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 ripple-lib-java with ISC License | 6 votes |
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: DeserializeTest.java From ig-json-parser with MIT License | 6 votes |
@Test public void postprocessTest() throws IOException, JSONException { final int value = 25; StringWriter stringWriter = new StringWriter(); JSONWriter writer = new JSONWriter(stringWriter); writer.object().key(PostprocessingUUT.FIELD_NAME).value(value).endObject(); String inputString = stringWriter.toString(); JsonParser jp = new JsonFactory().createParser(inputString); jp.nextToken(); PostprocessingUUT uut = PostprocessingUUT__JsonHelper.parseFromJson(jp); assertSame(value + 1, uut.getValue()); }
Example #3
Source File: DeserializeTest.java From ig-json-parser with MIT License | 6 votes |
@Test public void enumTest() throws IOException, JSONException { final EnumUUT.EnumType value = EnumUUT.EnumType.VALUE2; StringWriter stringWriter = new StringWriter(); JSONWriter writer = new JSONWriter(stringWriter); writer.object().key(EnumUUT.ENUM_FIELD_NAME).value(value.toString()).endObject(); String inputString = stringWriter.toString(); JsonParser jp = new JsonFactory().createParser(inputString); jp.nextToken(); EnumUUT uut = EnumUUT__JsonHelper.parseFromJson(jp); assertSame(value, uut.enumField); }
Example #4
Source File: DeserializeTest.java From ig-json-parser with MIT License | 6 votes |
@Test public void fieldAssignmentTest() throws IOException, JSONException { final int encodedValue = 25; final int deserializedValue = -encodedValue; StringWriter stringWriter = new StringWriter(); JSONWriter writer = new JSONWriter(stringWriter); writer.object().key(FormatterUUT.FIELD_ASSIGNMENT_FIELD_NAME).value(encodedValue).endObject(); String inputString = stringWriter.toString(); JsonParser jp = new JsonFactory().createParser(inputString); jp.nextToken(); FormatterUUT uut = FormatterUUT__JsonHelper.parseFromJson(jp); assertSame(deserializedValue, uut.getFieldAssignmentFormatter()); }
Example #5
Source File: DeserializeTest.java From ig-json-parser with MIT License | 6 votes |
@Test public void TypeFormatterImportsTest() throws IOException, JSONException { final String encodedValue = "test"; StringWriter stringWriter = new StringWriter(); JSONWriter writer = new JSONWriter(stringWriter); writer .object() .key("callee_ref") .object() .key("string_field") .value(encodedValue) .endObject() .endObject(); String inputString = stringWriter.toString(); TypeFormatterImportsContainerUUT container = TypeFormatterImportsContainerUUT__JsonHelper.parseFromJson(inputString); TypeFormatterImportsUUT uut = container.mTypeFormatterImports; assertTrue(uut instanceof TypeFormatterImportsCompanionUUT); assertEquals(encodedValue, uut.mString); }
Example #6
Source File: DeserializeTest.java From ig-json-parser with MIT License | 6 votes |
@Test public void importsTest() throws IOException, JSONException { final String encodedValue = "test"; final String deserializedValue = ":test"; StringWriter stringWriter = new StringWriter(); JSONWriter writer = new JSONWriter(stringWriter); writer.object().key("string_field").value(encodedValue).endObject(); String inputString = stringWriter.toString(); JsonParser jp = new JsonFactory().createParser(inputString); jp.nextToken(); ImportsUUT uut = ImportsUUT__JsonHelper.parseFromJson(jp); assertEquals(deserializedValue, uut.mStringField); }
Example #7
Source File: DeserializeTest.java From ig-json-parser with MIT License | 6 votes |
@Test public void valueExtractTest() throws IOException, JSONException { final int encodedValue = 25; final int deserializedValue = 40; StringWriter stringWriter = new StringWriter(); JSONWriter writer = new JSONWriter(stringWriter); writer.object().key(FormatterUUT.VALUE_FORMATTER_FIELD_NAME).value(encodedValue).endObject(); String inputString = stringWriter.toString(); JsonParser jp = new JsonFactory().createParser(inputString); jp.nextToken(); FormatterUUT uut = FormatterUUT__JsonHelper.parseFromJson(jp); assertSame(deserializedValue, uut.getValueFormatter()); }
Example #8
Source File: LedgerHeader.java From RipplePower with Apache License 2.0 | 6 votes |
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 #9
Source File: MilestoneChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(Milestone choice, JSONWriter writer) throws JSONException { writer.key("id").value(choice.getId()).key("name").value(HtmlEscape.escapeHtml5(choice.getName())); writer.key("statusName").value(choice.getStatusName()); if (choice.isClosed()) writer.key("statusClass").value("label-success"); else writer.key("statusClass").value("label-warning"); }
Example #10
Source File: AccountState.java From ripple-lib-java with ISC License | 5 votes |
public void writeEntriesArray(final JSONWriter writer) { writer.array(); walkEntries(new LedgerEntryVisitor() { @Override public void onEntry(LedgerEntry entry) { writer.value(entry.toJSON()); } }); writer.endArray(); }
Example #11
Source File: AccountState.java From RipplePower with Apache License 2.0 | 5 votes |
public void writeEntriesArray(final JSONWriter writer) { writer.array(); walkEntries(new LedgerEntryVisitor() { @Override public void onEntry(LedgerEntry entry) { writer.value(entry.toJSON()); } }); writer.endArray(); }
Example #12
Source File: Record.java From sndml3 with MIT License | 5 votes |
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 #13
Source File: AccountState.java From jingtum-lib-java with MIT License | 5 votes |
public void writeEntriesArray(final JSONWriter writer) { writer.array(); walkEntries(new LedgerEntryVisitor() { @Override public void onEntry(LedgerEntry entry) { writer.value(entry.toJSON()); } }); writer.endArray(); }
Example #14
Source File: PullRequestChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(PullRequest choice, JSONWriter writer) throws JSONException { writer .key("id").value(choice.getId()) .key("number").value(choice.getNumber()) .key("title").value(HtmlEscape.escapeHtml5(choice.getTitle())); }
Example #15
Source File: BuildChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(Build choice, JSONWriter writer) throws JSONException { writer .key("id").value(choice.getId()) .key("number").value(choice.getNumber()) .key("jobName").value(HtmlEscape.escapeHtml5(choice.getJobName())); if (choice.getVersion() != null) writer.key("version").value(HtmlEscape.escapeHtml5(choice.getVersion())); }
Example #16
Source File: AjaxSettings.java From onedev with MIT License | 5 votes |
void toJson(JSONWriter writer) throws JSONException { writer.object(); Json.writeFunction(writer, "data", data); Json.writeObject(writer, "dataType", dataType); Json.writeObject(writer, "quietMillis", quietMillis); Json.writeFunction(writer, "results", results); Json.writeObject(writer, "url", url); Json.writeObject(writer, "traditional", traditional); writer.endObject(); }
Example #17
Source File: IssueChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(Issue choice, JSONWriter writer) throws JSONException { writer .key("id").value(choice.getId()) .key("number").value(choice.getNumber()) .key("title").value(HtmlEscape.escapeHtml5(choice.getTitle())); }
Example #18
Source File: StringChoiceProvider.java From onedev with MIT License | 5 votes |
@Override public void toJson(String choice, JSONWriter writer) throws JSONException { String name = choicesModel.getObject().get(choice); if (name == null) name = choice; writer.key("id").value(choice).key("name").value(name); }
Example #19
Source File: LedgerHeader.java From jingtum-lib-java with MIT License | 5 votes |
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 #20
Source File: ServiceModelFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ServiceModelFormatter( JSONWriter writer ) { super( writer ); }
Example #21
Source File: AbstractProjectChoiceProvider.java From onedev with MIT License | 4 votes |
@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 #22
Source File: AbstractUserChoiceProvider.java From onedev with MIT License | 4 votes |
@Override public void toJson(User choice, JSONWriter writer) throws JSONException { writer.key("id").value(choice.getId()).key("name").value(HtmlEscape.escapeHtml5(choice.getDisplayName())); String avatarUrl = OneDev.getInstance(AvatarManager.class).getAvatarUrl(choice); writer.key("avatar").value(avatarUrl); }
Example #23
Source File: TextChoiceProvider.java From onedev with MIT License | 4 votes |
@Override public final void toJson(T choice, JSONWriter writer) throws JSONException { writer.key("id").value(getId(choice)).key("text").value(getDisplayText(choice)); }
Example #24
Source File: ObjectModelFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ObjectModelFormatter( JSONWriter writer ) { super(writer); }
Example #25
Source File: ArrayFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ArrayFormatter( JSONWriter writer, String name ) { super(writer); this.name = name; }
Example #26
Source File: ApplicationModelFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ApplicationModelFormatter( JSONWriter writer ) { super( writer ); }
Example #27
Source File: ValueModelFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ValueModelFormatter( JSONWriter writer ) { super(writer); }
Example #28
Source File: ModuleModelFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ModuleModelFormatter( JSONWriter writer ) { super( writer ); }
Example #29
Source File: MixinModelFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public MixinModelFormatter( JSONWriter writer ) { super( writer ); }
Example #30
Source File: ConstructorModelFormatter.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ConstructorModelFormatter( JSONWriter writer ) { super( writer ); }