MFC :: 修改json文件中的值
我能够在 MFC 中解析 json 文件,但很难修改这些值。除了将其转换为本机文件类型、修改内容并再次将其转换回 json 之外,是否有更简单的方法写入新值?
我认为这就像更改 XML 文件中的值一样简单,您只需查找标签并更改其值即可。
谢谢...
I'm able to parse json files in MFC but is having a hard time modifying the values. Is there an easier way writing new values, other than converting it to native file types, modifying the contents and converting it back to json again?
I thought it would be as easy as changing values in an XML file where you just look for the tag and change it's value.
thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 JSON Spirit 库。它遍历 json 文件的方式是通过它的键和值,它们被视为“对”。您所要做的就是循环遍历对象并搜索要替换的对。就是这样...
这里没有显示详细信息,但几乎为您提供了基础知识 -> http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx。它有很多方法可以用于您想要的任何操作。
:)
You can use JSON Spirit library. The way it traverses through the json file is through it's key and value which is treated as a "pair". All you have to do is loop through the objects and search for the pair you want to replace. That's it...
The details aren't shown here, but pretty much gives you the basics -> http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx. It's got a bunch of methods you could use for whatever operation you want.
:)