rok rok - 1 year ago 80
JSON Question

print json file content without line feed character in QT

I have this Json file:

"place": {
"id": "99"
"camera": {
"id": "99",
"url": "",

What i get is all the content printed in one line with character \n printed after each field and not as it is in the file. This happens on my Ubuntu machine, but not in another machine with Debian.
I'd like the file content printed line by line.. any hints?
I use this code to print the content of a Json file:

QString val;
QFile file;
file.setFileName("../config.json"); | QIODevice::Text);
val = file.readAll();
qWarning() << val;


Tried both solution provided by user TheDarkKnight with no luck, I also tried with
command in terminal and the file is printed correctly, so I suspect is not a matter of OS, but Qt is involved..

rok rok
Answer Source

Seems that qWarning() function escapes non-printable characters and add new line character at the end, so the solution is to use:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download