I want to get data from my Sqlite database and put it into this JSON file.
How can I create a json file and insert the data obtained from my database into the JSON file?
I want data in JSON file in this format:
{
"data": [
{
"data": [
null,
null,
30,
45,
69,
70,
65
],
"title": "title5"
},
{
"data": [
null,
5,
10,
15,
22,
30
],
"title": "title4"
},
{
"data": [
40,
55,
],
"title": "title3"
},
{
"data": [
null,
89,
90,
85
],
"title": "title2"
},
{
"data": [
66,
77,
55,
33,
50,
-6,
-8
],
"title": "title1"
}
],
"x_labels": [
6,
7,
8,
9,
10,
11,
12
]
}
How can I do this?
Create Obj C object reading data from your sqlite database. Say
proxyForJsonmethod, since its a user defined object.You can make a JSON string from an object ,
I am not sure if it works directly for array, if not, encapsulate your dataArray in anotherObject, and send that object to this JSON writer.
Write the JSON string to a file.