在Java中动态修改未知JSON的JsonNode(Modify JsonNode of unknown JSON dynamically in Java)
我试图修改一个JSON(未知结构),其中JsonPath及其等效的XML Xpath是我所知道的。
我已经厌倦了使用
com.jayway.jsonpath.JsonPath
库。 JsonPath的问题是,它返回值但我无法修改目标节点。以下是我的代码片段
JsonPath.read(jsonFile, jsonPath); JsonPath.parse(jsonPath); System.out.println("Author: "+JsonPath.read(jsonFile, jsonPath));
我尝试使用杰克逊,如前面提到的排队中提到的,但它需要逐个节点遍历,如下所示
((ObjectNode) parent).put(fieldName, newValue);
由于结构未知,我无法做到这一点。
我已经尝试了递归解析JSON对象的问题的答案,但它说如何解析不修改
我需要做以下几点
JsonNode root = mapper.readTree("Json in form of String"); ((JsonNode)(root.get("JsonPath")).set("New Value");
有什么办法可以实现这一目标吗?
I am trying to modify a JSON (of an unknown structure) where the JsonPath and its equivalent XML Xpath is known to me.
I have tired using
com.jayway.jsonpath.JsonPath
library for the same. The problem with JsonPath is, it returns me the value but I am not able to modify the Target Node.Follows is my code snippet for the same
JsonPath.read(jsonFile, jsonPath); JsonPath.parse(jsonPath); System.out.println("Author: "+JsonPath.read(jsonFile, jsonPath));
I tried using Jackson as mentioned in previously asked quetion, But it needs to be traversed node by node as follows
((ObjectNode) parent).put(fieldName, newValue);
which I cannot do due to unknown structure.
I have tried the answer given to the question recursively parse JSON object but it says how to parse not modify
I need to do the follows
JsonNode root = mapper.readTree("Json in form of String"); ((JsonNode)(root.get("JsonPath")).set("New Value");
Is there any way in which this can be achieved?
原文:https://stackoverflow.com/questions/41360172
最满意答案
这适用于chrome和firefox中的4个
@font-face { font-family: 'myFnt'; src: url('webfonts/name.ttf'); font-weight: normal; font-style: normal; }
你在使用.htaccess文件吗? 如果是,请将.ae放在.htaccess文件中
<FilesMatch "\.(ttf|otf|eot)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch>
在这里你可以阅读解决方案font-face不仅仅工作firefox
this works for 4 in chrome and firefox as well
@font-face { font-family: 'myFnt'; src: url('webfonts/name.ttf'); font-weight: normal; font-style: normal; }
are you using a .htaccess file? If yes put theae on your .htaccess file
<FilesMatch "\.(ttf|otf|eot)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch>
here you can read the solution font-face not working only firefox
相关问答
更多-
尝试创建嵌入的字体对象并使用此字体呈现文本: //this code should run once at initialization/application startup FontFactory.register("resources/wingding_font.ttf"); Font textFont = FontFactory.getFont("wingding", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10); //10 is the size ...
-
出于隐私原因,图像必须完全独立,即一个文件中的所有内容。 如果您希望在将SVG用作图像时(在图像标记中或作为CSS图像背景)中使用ttf字体,则必须对其进行base64编码并将其作为数据URL嵌入到图像中。 @font-face { font-family: 'LHF'; src: url("data:application/x-font-ttf;base64,[base-encoded font here]"); } 或者,您可以使用
从外部路径加载TTF字体(Load TTF font from external path)[2022-04-27]
是的,你可以做到这一点。 只需将字体复制到您的项目中,并在您的info.plist中添加此参考。 然后,您可以像任何其他系统字体一样引用字体名称。 Yes, you can do this. Just copy the font to your project and add this reference in your info.plist. Then you can reference the font name just like any other system font./* Read the documenation at https://github.com/bpampuch/pdfmake specially the readme file */my first pdfmake example ...如何在Cygwinx上使用第三方TTF字体?(How do I use third party TTF fonts on Cygwinx? How about Windows fonts?)[2022-11-08]
cygwin使用的窗口字体的子集由postinstall脚本定义 /etc/postinstall/zp_fontconfig_cache_1.sh Windows字体链接在/usr/share/fonts/microsoft 在我的系统中,选择了C:\windows\Fonts下350个存在的229个。 您可以将您的额外字体复制到相同的目录中并运行相同的脚本。 The subset of windows fonts used by cygwin is defined by postinstall scri ...解决了! 我分开srcs ,就像那样: @font-face font-family: "Alef" src: url("..\..\public\fonts\Alef\Alef-Webfont\Alef-Bold.eot") src: url("..\..\public\fonts\Alef\Alef-Webfont\Alef-Bold.eot?#iefix") format("embedded-opentype") src: url("..\..\public\font ...这适用于chrome和firefox中的4个 @font-face { font-family: 'myFnt'; src: url('webfonts/name.ttf'); font-weight: normal; font-style: normal; } 你在使用.htaccess文件吗? 如果是,请将.ae放在.htaccess文件中... 您需要使路径相对 - css加载器不会将绝对路径视为webpack资源 。 对于以/开头的网址,默认行为是不翻译它们: url(/image.png) => url(/image.png) You need to make your paths relative - the css loader does not treat absolute paths as webpack resources. For urls that start with a /, the default behavior is ...有些IE版本与ttf不兼容,请看这里: Internet Explorer中TTF支持的状态是什么? 你可能需要一个.eot后备: @font-face { font-family: 'CAROBTN'; src: url('fonts/CAROBTN_.ttf'), url('fonts/CAROBTN_.eot'); } 您可以在此处转换字体文件: https : //www.fontsquirrel.com/tools/webfont-generator Some IE versio ...除了其他评论 更换 Font Iomanoid = new Font("Iomanoid", Font.BOLD, 40); 通过 Font iomanoid = myFont.deriveFont(Font.BOLD, 40f); 之后这个字体需要注册(如mushfek0001所述) 有关字体的更多信息,请查看有关物理和逻辑字体的Oracle教程 Beside other comments replace Font Iomanoid = new Font("Iomanoid", Font.BOLD, ...相关文章
更多- Jackson树模型JsonNode
- JSON是什么?
- 动态拼接JSON数组的问题
- XStream处理JSON
- JSON 语法
- net.sf.json解析json对象
- Jackson JSON映射到任何Java对象
- 使用Gson解析Json数据
- 怎么递归json嵌套json?
- JSON 数据类型
最新问答
更多- 使用通配符获取更多servlet请求变量[重复](Get more servlet request variables using wildcards [duplicate])
- 返回相同的集合类型,参数化不同(Returning same collection type, differently parameterised)
- C ++朋友函数模板重载和SFINAE在clang ++,g ++,vc ++中的不同行为(C ++ 14模式)(C++ friend function template overloading and SFINAE different behaviors in clang++, g++, vc++ (C++14 mode))
- 与paure IoT-Hub的Python paho-MQTT连接(Python paho-MQTT connection with azure IoT-Hub)
- 编译器警告“来自不同的Objective-C类型的赋值”(Compiler warning “assignment from distinct objective-c type”)
- C ++编译错误(在此函数中未初始化)[重复](C++ Compile Error (uninitialized in this function) [duplicate])
- unsigned-signed下溢机制(unsigned-signed underflow mechanism)
- 快速行查询的数据结构?(Data structure for fast line queries?)
- 饥荒有手机安卓版的吗
- Jquery可拖动碰撞检测错误(Jquery draggable collision detection bug)
- sql调优是怎样来实现的?
- 无法使占位符输入文本消失(Unable to make the placeholder input text disappear)
- jQuery改变了两个div的CSS属性(JQuery change CSS property of two div's)
- JDK中包含的库版本(Versions of libraries included in the JDK)
- 请问下载的是出现ASP是什么意思
- Firebase MLkit用于数字液晶显示器的文本识别(Firebase MLkit Text recognition for digital lcd displays)
- 我可以在任何平台上运行C和C ++吗?(Can I run C and C++ on any platform?)
- 让小组在C#的特定位置(get panel at specific positions in C#)
- Nagios为通知设置了更高的间隔(Nagios set higher interval for notifications)
- 无法向SMTP主机发送电子邮件(unable to send an email to SMTP host)
- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何在.NET代码中验证全球邮政编码(How can I validate worldwide postal codes in my .NET code)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- Clojure:减少大型懒惰收集会占用内存(Clojure: Reducing large lazy collection eats up memory)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- 显示作为字符串的SVG(Showing an SVG that I have as a string)
- 从jansson库里创建json请求的自由内存的正确方式是什么?(what is the proper way of free memory in creating json request from jansson libary?)
- jQuery插件无法正常工作 - 它是附加的(jQuery plugin not working - it's appended)
- 使用stat_summary自动调整ylim(Automatically adjusting ylim with stat_summary)