Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost: Why write_json changing content

Tags:

c++

json

boost

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:

input:

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

is changed to:

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

Is this a bug? How to fix it?

like image 546
thedarkside ofthemoon Avatar asked Oct 01 '22 19:10

thedarkside ofthemoon


1 Answers

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.

like image 150
jfly Avatar answered Oct 19 '22 12:10

jfly