I import a JSON file in my program and I need to read & edit it.
(Only use QML not QT)
Reading part works totally fine , but writing part doesn't.
This is I try to use XMLHttpRequest sending my data to a json file(through qml workerScript)
"qrc:/1122test.json" is the json file's URL in my program
WorkerScript.onMessage = function(message) {
var xhr = new XMLHttpRequest;
xhr.open("POST" , "qrc:/1122test.json");
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
xhr.onreadystatechange = function(){
console.log("1122state" , xhr.readyState);
if(xhr.readyState == 4){
// console.log("1122state" , xhr.readyState);
}
}
xhr.send(JSON.stringify({"email":"test@user.com" , "response":{"name" : "newName"}} ));
console.log("saveed");
}
and my json file example
{
"email":"hi@user.com" ,
"response": {
"name":"tester"
}
}
Every time I open terminal cat the json file , it remain same("hi@user.com" didn't change to "test@user.com" and so was name part)
I already changed the json file's authority to 777
Every log in java showed but not show any error code.
This bother me for over a week , really appreciate any idea !!!