使用Jackson数据绑定跳过嵌套字段?(Skipping nested field with Jackson data binding?)
我如何使用Jackson将以下json片段绑定(双向)到下面的Java对象?
我希望Json新闻稿节点的键/值对最终位于新闻稿字段的Map中。 什么必须是杰克逊配置(注释和其他)绑定这个? 对不起,我不知道如何:((使用最新版本的杰克逊)。
下面的Json格式是固定的,我从第三方休息服务(我无法更改)接收它。 我可以更改java代码,但更喜欢下面的设置。
JSON:
{ "newsletter": { "key1": "value1", "key2": "value2", "key3": "value3" } }
Java对象:
class Preferences { private NewsLetter newsLetter; // getter/setter for field newsLetter. } class NewsLettter { private Map<String, String> properties; // getter/setter for field properties. }
How must I bind (bidirectional) the following json snippet to the Java objects below with Jackson?
I want the key/value pairs of the Json newsletter node to end up in the Map of the newsletter field. What must be the Jackson config (annotations and others) to bind this ? Sorry, I don't know how :( (using the latest version of Jackson).
The Json format below is fixed, I receive it from a third party rest service (I can't change it). I can change the java code, but prefer the setup below.
JSON:
{ "newsletter": { "key1": "value1", "key2": "value2", "key3": "value3" } }
The Java Objects:
class Preferences { private NewsLetter newsLetter; // getter/setter for field newsLetter. } class NewsLettter { private Map<String, String> properties; // getter/setter for field properties. }
原文:https://stackoverflow.com/questions/31752242
最满意答案
相关问答
更多-
通过将属性Text Alignment设置为Center来解决该问题。 似乎默认情况下由“Center:Inherited”设置,所以这里是正确解决方案的步骤: 将属性Text Alignment设置为另一个值(Ex:Justify) 保存报告 再次使用正确的值“Center”设置属性Text Alignment 保存报告 只有遵循这些步骤才能正确设置属性。 The problem was solved by setting the property Text Alignment to Center. It ...
-
如何在Android平板电脑HTML veiwer上滚动横幅广告?(How can scrolling banner work on Android tablet HTML veiwer?)[2022-12-07]
你必须安装Android版本的Adobe Flash,但由于Adobe不再支持Android平台,我强烈建议你用你的Android应用程序中的HTML5 + Javascript或Java代码替换你的swf 。 You have to install the Android version of Adobe Flash, but since Adobe no longer supports the Android platform, I'd strongly suggest you replace your ... -
两天后,我终于解决了这个问题。 我注意pcl :: visualization :: PCLVisualizer的构造函数以及“SpinOnce”函数,我认识到如果你放一个静态锁,这样只有多个对象中的一个线程可以访问这些函数,那么问题就解决了。 以前,我在这些函数上放置了非静态锁,正如您所知,本地锁只在它们创建的同一对象中工作(不是从类中实例化的整个对象)。 所以我在my_vis类中定义了一个静态锁: private static boost::mutex vis_mutex; boost ...
-
这是一个Sankey图,边缘的宽度与节点之间传输的量成比例。 https://en.wikipedia.org/wiki/Sankey_diagram 关于SO的答案表明rCharts可用于创建此类图。 It's a Sankey Diagram, where the width of the edges is proportional to the amount transferred between nodes. https://en.wikipedia.org/wiki/Sankey_diagram ...
-
Jenya Kirmiza, 大小类是你想要的:)大小类是在iOS8中引入的,以避免通用应用程序的多个故事板,并为开发人员提供了一种简单的方法来为不同的设备设计不同的UI :) 我希望你知道SizeClasses,如果你不知道每个设备的各种方向都属于Apple定义的sizeClass之一。 这里需要注意的一点是iPad的两个方向都属于Regular x Regular size class 除iphone 6S和iphone 6s +之外的所有iPhone都将落到 Copact Width x Regula ...
-
为什么AWS Cloudfront未将Tablet设备归类为Tablet?(Why AWS Cloudfront not classifying Tablet device as Tablet?)[2023-03-31]
根据User-Agent标头的值,CloudFront会在将请求转发到您的源之前将这些标头的值设置为true或false。 如果某个设备属于多个类别,则可能有多个值。 例如,对于某些平板电脑设备,CloudFront可能会将CloudFront-Is-Mobile-Viewer和CloudFront-Is-Tablet-Viewer设置为true。 (重点补充) http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header- ... -
用Dart可视化?(Visualization with Dart?)[2022-08-04]
感谢dart:js你可以使用任何js lib。 有关详细信息,请参阅使用Dart中的JavaScript 。 Thanks to dart:js you can use any js lib. See Using JavaScript from Dart for more details. -
TABLET一次不支持多个BAM文件(至少暂时)。 因此可以使用其他可视化器,例如IGV , SAVANT ,它支持多个BAM可视化 TABLET doesn't support more than one BAM File at a time (For time being at least). So can go with other visualizers such as IGV, SAVANT which supports more than one BAM visualization
-
灵感来自https://stackoverflow.com/a/5808864/2339680我想问题是,vtkRenderWindow仅作为前向声明可用于编译器。 如果你包括 #include "vtkRenderWindow.h" 在一开始,一切都应该编译。 With inspiration from https://stackoverflow.com/a/5808864/2339680 i guess that the problem is, that vtkRenderWindow is only ...
-
刚发现他们有更新...... 看来,当我们推出新版本时,系统会出现一些小问题,直到更改完全传播为止。 我们将来会努力解决这个问题,但是现在,如果你遇到这些错误,我建议你刷新页面,如有必要,刷新你的缓存。 您还可以将“当前”更改为“43”或“44”,它将更可靠地工作。 将其更改为44 google.charts.load('44',为我工作! 感谢https://stackoverflow.com/a/35661581/1700554 Just found out they had an update... ...