Using external Json file in QML [Qt5/QML2]
-
wrote on 1 Dec 2012, 17:23 last edited by
Hey Qt-Project members
I've tried the last 3 hours getting a external Json file loading in my QML / Javascript logic.
@ var jsonObj ={"test" : ["a","b","c","d","e","f","g","h"],}
...
console.log(jsonObj.test[0])@This works quite well but is there a way to store the Json data in a separate file?
thanks
Eli -
wrote on 3 Dec 2012, 00:01 last edited by
Hi,
Use the LocalStorage submodule of QtQuick2 to store things to a database. Alternatively, write your own simple file storage QObject-derived type, and expose it as a singleton type or ordinary type, and use it to write out the string to file. You can use JSON.parse() and JSON.stringify() in the JS environment supported by QML in Qt5.
Cheers,
Chris. -
wrote on 4 Dec 2012, 14:23 last edited by
Thanks but it looks like the easiest way to solve this is to write an Json object in an normal javascript file :)
Eli
1/3