1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import qbs
import qbs.Process
import qbs.PropertyList
import qbs.TextFile
Product {
type: {
var obj = {
"Array": ["ListItem1", "ListItem2", "ListItem3"],
"Integer": 1,
"Boolean": true,
"String": "otherString"
};
var infoplist = new TextFile("test.xml", TextFile.WriteOnly);
infoplist.write(JSON.stringify(obj));
infoplist.close();
var process = new Process();
process.exec("plutil", ["-convert", "xml1", "test.xml"]);
process.close();
var xmlfile = new TextFile("test.xml", TextFile.ReadOnly);
var propertyList = new PropertyList();
propertyList.readFromString(xmlfile.readAll());
xmlfile.close();
var jsontextfile = new TextFile("test.json", TextFile.WriteOnly);
jsontextfile.write(propertyList.toJSONString());
jsontextfile.close();
process = new Process();
process.exec("plutil", ["-convert", "json", "test.xml"]);
process.close();
return "Pineapple Steve";
}
}
|