我有应用程序服务器,比如App1将JSON中的REST POST发送到另一台服务器,比如说某个路径上的server1(server1 / path)。每次发布某些内容并执行某些操作时,如何从JSON POST中读取字段。
我目前正在使用Jackson API,这是我目前所拥有的:
mainTabBar.Items.Each((UITabBarItem item, int index) =>
{
item.BadgeValue = "Normal";
foreach (var badgeView in mainTabBar.Subviews[index].Subviews)
{
if (index > 0)
if (badgeView.Class.Name.Contains("_UIBadgeView"))
{
badgeView.Layer.Transform = new CATransform3D();
badgeView.Layer.Transform = CATransform3D.MakeTranslation(-100, -20, 1);
item.BadgeValue = "Custom";
item.BadgeColor = UIColor.Green;
item.SetBadgeTextAttributes(new UIStringAttributes() { ForegroundColor = UIColor.Black }, UIControlState.Normal);
return;
}
}
});
@POST
@Path("tcp")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getInfo(InputStream stream) throws IOException {
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
JsonNode someField = jsonTree.get("fieldname");
if (someField != null) {
throw new IllegalArgumentException("Invalid field in post request");
// Do something with someField here everytime something is POSTed....
}
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
return Response.ok(root).build();
}
是here
mapper()
套件提供的方法