本文整理汇总了Java中ratpack.jackson.Jackson类的典型用法代码示例。如果您正苦于以下问题:Java Jackson类的具体用法?Java Jackson怎么用?Java Jackson使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Jackson类属于ratpack.jackson包,在下文中一共展示了Jackson类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handle
import ratpack.jackson.Jackson; //导入依赖的package包/类
@Override
public void handle(Context context) throws Exception {
try {
Blocking.get(
() -> config.authenticate(injector, config.getInput(context))
).onError(t -> {
if (t.getClass().equals(AuthenticationFailed.class)) {
AuthenticationFailed failure = (AuthenticationFailed) t;
context.getResponse().status(failure.getHttpStatus()).send(failure.getMessage());
}
}).then(claims -> {
String token = jwtSigner.sign(claims.toMap());
context.render(Jackson.json(token));
});
} catch (ParserException e) {
LOGGER.info("Failed to parse Credential", e);
context.getResponse().status(400).send();
}
}
开发者ID:ylemoigne,项目名称:ratpack-jwtauth,代码行数:20,代码来源:LoginHandler.java
示例2: render
import ratpack.jackson.Jackson; //导入依赖的package包/类
@Override
public void render(Context context, Book book) throws Exception {
context.byContent(byContentSpec -> byContentSpec
.json(() ->
context.render(Jackson.json(book))
)
.xml(() -> {
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.configure(WRITE_XML_DECLARATION, true);
context.render(xmlMapper.writeValueAsString(book));
})
);
}
开发者ID:danveloper,项目名称:hands-on-ratpack-java,代码行数:14,代码来源:BookRenderer.java
示例3: handle
import ratpack.jackson.Jackson; //导入依赖的package包/类
public void handle(final Context ctx, final BotOrchestrationService botOrchestrationService, final HipChatRequestValidator requestValidator) throws Exception {
ctx.byMethod(m -> m
.post(() -> ctx.parse(Jackson.fromJson(RoomMessage.class))
.next(msg -> botOrchestrationService.getActiveInstallationByOauthId(msg.getOauthId()).ifPresent(installation -> requestValidator.validate(ctx.getRequest(), installation.getOauthSecret())))
.next(botOrchestrationService::onRoomMessage)
.then(msg -> ctx.getResponse().status(Status.OK).send())
)
);
}
开发者ID:RoyJacobs,项目名称:lazybot,代码行数:10,代码来源:RoomMessageHandler.java
示例4: getInput
import ratpack.jackson.Jackson; //导入依赖的package包/类
@Override
public <T> T getInput(Context context, Class<T> javaType) throws Exception {
return Blocking.on(context.parse(Jackson.fromJson(javaType)));
}
开发者ID:ylemoigne,项目名称:ratpack-jwtauth,代码行数:5,代码来源:InputType.java
注:本文中的ratpack.jackson.Jackson类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论