Revision 49200
Added by Alessia Bardi over 6 years ago
JacksonTest.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.io.StringWriter; |
5 |
import java.util.UUID; |
|
5 | 6 |
|
6 | 7 |
import com.fasterxml.jackson.core.JsonFactory; |
7 | 8 |
import com.fasterxml.jackson.core.JsonGenerator; |
... | ... | |
54 | 55 |
jgen.close(); |
55 | 56 |
System.out.println(sw.getBuffer().toString()); |
56 | 57 |
} |
58 |
|
|
59 |
@Test |
|
60 |
public void testHeader() throws IOException { |
|
61 |
JsonFactory jsonFactory = new JsonFactory(); |
|
62 |
StringWriter sw = new StringWriter(); |
|
63 |
JsonGenerator jgen = jsonFactory.createGenerator(sw); |
|
64 |
jgen.writeStartObject(); |
|
65 |
jgen.writeObjectFieldStart("header"); |
|
66 |
jgen.writeStringField("uuid", UUID.randomUUID().toString()); |
|
67 |
jgen.writeEndObject(); |
|
68 |
jgen.writeStringField("@class", "specificType"); |
|
69 |
jgen.writeArrayFieldStart("consistsOf"); |
|
70 |
jgen.writeEndArray(); |
|
71 |
jgen.writeEndObject(); |
|
72 |
|
|
73 |
jgen.close(); |
|
74 |
System.out.println(sw.getBuffer().toString()); |
|
75 |
} |
|
57 | 76 |
} |
Also available in: Unified diff
More mapping to gcube resources and facets