Skip to content

Commit 5b0fbcd

Browse files
committed
Change toJson() methods on JsonView/Type to have value as first argument
1 parent 7001879 commit 5b0fbcd

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

blackbox-test/src/test/java/org/example/customer/CustomerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void toJson_writer() {
7272
JsonType<Customer> customerType = jsonb.type(Customer.class);
7373
StringWriter sw = new StringWriter();
7474

75-
customerType.toJson(sw, customer);
75+
customerType.toJson(customer, sw);
7676
assertThat(sw.toString()).startsWith(jsonStart);
7777
}
7878

@@ -130,7 +130,7 @@ void toJson_pretty() {
130130
try (JsonWriter writer = jsonb.writer(stringWriter)) {
131131
writer.pretty(true);
132132
Customer customer = new Customer().id(42L).name("rob").status(Customer.Status.ACTIVE);
133-
jsonb.type(Customer.class).toJson(writer, customer);
133+
jsonb.type(Customer.class).toJson(customer, writer);
134134
}
135135
String prettyJson = stringWriter.toString().replace("\" : ", "\": ");
136136
assertThat(prettyJson).isEqualTo("""
@@ -155,7 +155,7 @@ void toJsonStream() {
155155
try (JsonWriter jsonWriter = jsonb.writer(writer)) {
156156
jsonWriter.pretty(false);
157157
for (Customer customer : customers) {
158-
type.toJson(jsonWriter, customer);
158+
type.toJson(customer, jsonWriter);
159159
jsonWriter.writeNewLine();
160160
}
161161
}
@@ -190,10 +190,10 @@ <T> void toStream(Iterator<T> iterator, JsonWriter jsonWriter) {
190190
jsonWriter.pretty(false);
191191
T first = iterator.next();
192192
JsonType<T> type = jsonb.typeOf(first);
193-
type.toJson(jsonWriter, first);
193+
type.toJson(first, jsonWriter);
194194
jsonWriter.writeNewLine();
195195
while (iterator.hasNext()) {
196-
type.toJson(jsonWriter, iterator.next());
196+
type.toJson(iterator.next(), jsonWriter);
197197
jsonWriter.writeNewLine();
198198
}
199199
}

blackbox-test/src/test/java/org/example/customer/SomeAddressWrapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void includeNull() {
3636
writer.serializeEmpty(true);
3737

3838
var type = jsonb.type(SomeAddressWrapper.class);
39-
type.toJson(writer, new SomeAddressWrapper(43L, null, Collections.emptyList()));
39+
type.toJson(new SomeAddressWrapper(43L, null, Collections.emptyList()), writer);
4040
writer.close();
4141
assertThat(sw.toString()).isEqualTo("{\"id\":43,\"address\":null,\"tags\":[]}");
4242
}

0 commit comments

Comments
 (0)