-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96dd040
commit ce457af
Showing
6 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/java/com/fasterxml/jackson/failing/TestIterable358.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import java.io.IOException; | ||
import java.util.*; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
public class TestIterable358 extends BaseMapTest | ||
{ | ||
// [Issue#358] | ||
static class A { | ||
public String unexpected = "Bye."; | ||
} | ||
|
||
static class B { | ||
@JsonSerialize(as = Iterable.class, contentUsing = ASerializer.class) | ||
public List<A> list = Arrays.asList(new A()); | ||
} | ||
static class ASerializer extends JsonSerializer<A> { | ||
@Override | ||
public void serialize(A a, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException { | ||
jsonGenerator.writeStartArray(); | ||
jsonGenerator.writeString("Hello world."); | ||
jsonGenerator.writeEndArray(); | ||
} | ||
} | ||
|
||
final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
||
public void testIterable358() throws Exception { | ||
String json = MAPPER.writeValueAsString(new B()); | ||
assertEquals("{\"list\":[[\"Hello world.\"]]}", json); | ||
} | ||
|
||
} |