升压:为什么write_json更改内容 [英] Boost: Why write_json changing content

查看:263
本文介绍了升压:为什么write_json更改内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取和保存json文件.问题是,当我调用write_json(pt, "newFile.json")时,它正在更改某些字段的内容,例如:

I am trying to read and save a json file. The problem is that when I call write_json(pt, "newFile.json") it is changing the content of some fields like:

输入:

"field1":"path/to/file.txt"

更改为:

"field1":"path\/to\/file.txt"

这是一个错误吗?如何解决?

Is this a bug? How to fix it?

推荐答案

这意味着它转义了正斜杠. JSON 规范说,您可以转义正斜杠,但这不是强制性的.由于这个原因,此处是一个很好的解释.

It means it escapes the forward slash. The JSON spec says you can escape forward slash, but it's not mandatory. As for the reason, here is a good explanation.

这篇关于升压:为什么write_json更改内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆