BAEL-6310 - updated indent
This commit is contained in:
parent
af4f179335
commit
53bb8da097
@ -12,81 +12,81 @@ public class JacksonJrFeatures {
|
|||||||
|
|
||||||
public static String jsonObject() throws IOException {
|
public static String jsonObject() throws IOException {
|
||||||
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
||||||
.asString(new LinkedHashMap<String, Object>() {{
|
.asString(new LinkedHashMap<String, Object>() {{
|
||||||
put("name", "John Doe");
|
put("name", "John Doe");
|
||||||
put("age", 30);
|
put("age", 30);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String jsonComposer() throws IOException {
|
public static String jsonComposer() throws IOException {
|
||||||
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
||||||
.composeString()
|
.composeString()
|
||||||
.startObject()
|
.startObject()
|
||||||
.startArrayField("objectArray")
|
.startArrayField("objectArray")
|
||||||
.startObject()
|
.startObject()
|
||||||
.put("name", "name1")
|
.put("name", "name1")
|
||||||
.put("age", 11)
|
.put("age", 11)
|
||||||
.end()
|
.end()
|
||||||
.startObject()
|
.startObject()
|
||||||
.put("name", "name2")
|
.put("name", "name2")
|
||||||
.put("age", 12)
|
.put("age", 12)
|
||||||
.end()
|
.end()
|
||||||
.end()
|
.end()
|
||||||
.startArrayField("array")
|
.startArrayField("array")
|
||||||
.add(1)
|
.add(1)
|
||||||
.add(2)
|
.add(2)
|
||||||
.add(3)
|
.add(3)
|
||||||
.end()
|
.end()
|
||||||
.startObjectField("object")
|
.startObjectField("object")
|
||||||
.put("name", "name3")
|
.put("name", "name3")
|
||||||
.put("age", 13)
|
.put("age", 13)
|
||||||
.end()
|
.end()
|
||||||
.put("last", true)
|
.put("last", true)
|
||||||
.end()
|
.end()
|
||||||
.finish();
|
.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String objectSerialization(Person person) throws IOException {
|
public static String objectSerialization(Person person) throws IOException {
|
||||||
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
||||||
.asString(person);
|
.asString(person);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String objectAnnotationSerialization(Person person) throws IOException {
|
public static String objectAnnotationSerialization(Person person) throws IOException {
|
||||||
return JSON.builder()
|
return JSON.builder()
|
||||||
.register(JacksonAnnotationExtension.std)
|
.register(JacksonAnnotationExtension.std)
|
||||||
.build()
|
.build()
|
||||||
.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
||||||
.asString(person);
|
.asString(person);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String customObjectSerialization(Person person) throws IOException {
|
public static String customObjectSerialization(Person person) throws IOException {
|
||||||
return JSON.builder()
|
return JSON.builder()
|
||||||
.register(new JacksonJrExtension() {
|
.register(new JacksonJrExtension() {
|
||||||
@Override
|
@Override
|
||||||
protected void register(ExtensionContext extensionContext) {
|
protected void register(ExtensionContext extensionContext) {
|
||||||
extensionContext.insertProvider(new MyHandlerProvider());
|
extensionContext.insertProvider(new MyHandlerProvider());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
||||||
.asString(person);
|
.asString(person);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Person objectDeserialization(String json) throws IOException {
|
public static Person objectDeserialization(String json) throws IOException {
|
||||||
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
return JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
||||||
.beanFrom(Person.class, json);
|
.beanFrom(Person.class, json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Person customObjectDeserialization(String json) throws IOException {
|
public static Person customObjectDeserialization(String json) throws IOException {
|
||||||
return JSON.builder()
|
return JSON.builder()
|
||||||
.register(new JacksonJrExtension() {
|
.register(new JacksonJrExtension() {
|
||||||
@Override
|
@Override
|
||||||
protected void register(ExtensionContext extensionContext) {
|
protected void register(ExtensionContext extensionContext) {
|
||||||
extensionContext.insertProvider(new MyHandlerProvider());
|
extensionContext.insertProvider(new MyHandlerProvider());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
.with(JSON.Feature.PRETTY_PRINT_OUTPUT)
|
||||||
.beanFrom(Person.class, json);
|
.beanFrom(Person.class, json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user