質問

Is there any way to change a single value in an already existing JSON file with JSONcpp? I want to preserve the existing formatting (comments, spaces, line breaks) in the file.

Example: find the value with key "test_boolean" in C:/test.json and make its value "false", leaving everything else as it is.

I've tried using Json::StyledStreamWriter, both with the root of the value I want to change, and the value itself. In the first case, the entire file was rewritten, with the new value, but no formatting or comments were preserved. In the second case, only "false" was written in the entire file.

役に立ちましたか?

解決

According to my tests/research, it is impossible to modify a single value in a JSON maintaining the current formatting, using JSONcpp.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top