Create,Edit,delete and view Json data
Moderator: Martin
Create,Edit,delete and view Json data
Hi all
I want a simple example flow how to create ,Edit, Delete and view Json data
I am in a bit confusion about json.
Thanks in advance for post.
from record4
I want a simple example flow how to create ,Edit, Delete and view Json data
I am in a bit confusion about json.
Thanks in advance for post.
from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1
Samsung Galaxy j2 non rooted.
Android 5.1.1
Re: Create,Edit,delete and view Json data
What kind of json data you need to work with? It is a good practice to always use fromJSON() and toJSON() to convert json first to object, edit it and then convert back to json afterward.
You can search the forum for various usage example
viewtopic.php?f=5&t=8458&p=26620&hilit=json#p26620
viewtopic.php?f=5&t=8429&p=26493&hilit=json#p26493
viewtopic.php?f=5&t=8393&p=26297&hilit=json#p26297
But most json need is unique, so need to see the structure first.
You can search the forum for various usage example
viewtopic.php?f=5&t=8458&p=26620&hilit=json#p26620
viewtopic.php?f=5&t=8429&p=26493&hilit=json#p26493
viewtopic.php?f=5&t=8393&p=26297&hilit=json#p26297
But most json need is unique, so need to see the structure first.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Create,Edit,delete and view Json data
Desmanto is right.
I use JSON a lot now getting data from APIs. They are all structured differently. But with DEBUG DIALOG and plenty of trial and error you can get the data you want.
Good luck
I use JSON a lot now getting data from APIs. They are all structured differently. But with DEBUG DIALOG and plenty of trial and error you can get the data you want.
Good luck
Crude but it works.
Re: Create,Edit,delete and view Json data
Hi Desmanto
Hi I have already tried this. But I am still in confusion how to create,view,delete and edit data?
In this below example how can I get all names values in a list and how to enter,edit and delete data?
peopleList =
'{"people" :[{"name":"Micky","phone":"012345678","birthday":"0101"},{"name":"Mickey","phone":"12345678","birthday":"0202"},{"name":"Michael ","phone":"2345678","birthday":"0303"},{"name":"Micheal","phone":"345678","birthday":"0404"},{"name":"Mike","phone":"567890","birthday":"0505"}]}';
js = fromJSON (peopleList);
len = length (js["people"]);
name = js["people"][a]["name"];
phone = js["people"][a]["phone"];
birthday = js["people"][a]["birthday"];
Thanks a lot from record4
Hi I have already tried this. But I am still in confusion how to create,view,delete and edit data?
In this below example how can I get all names values in a list and how to enter,edit and delete data?
peopleList =
'{"people" :[{"name":"Micky","phone":"012345678","birthday":"0101"},{"name":"Mickey","phone":"12345678","birthday":"0202"},{"name":"Michael ","phone":"2345678","birthday":"0303"},{"name":"Micheal","phone":"345678","birthday":"0404"},{"name":"Mike","phone":"567890","birthday":"0505"}]}';
js = fromJSON (peopleList);
len = length (js["people"]);
name = js["people"][a]["name"];
phone = js["people"][a]["phone"];
birthday = js["people"][a]["birthday"];
Thanks a lot from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1
Samsung Galaxy j2 non rooted.
Android 5.1.1
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Create,Edit,delete and view Json data
peopleList =
'{"people" :[{"name":"Micky","phone":"012345678","birthday":"0101"},{"name":"Mickey","phone":"12345678","birthday":"0202"},{"name":"Michael ","phone":"2345678","birthday":"0303"},{"name":"Micheal","phone":"345678","birthday":"0404"},{"name":"Mike","phone":"567890","birthday":"0505"}]}';
js = fromJSON (peopleList);
len = length (js["people"]);
extractedList = newList ();
for (a in [0 to len - 1])
{
name = js["people"][a]["name"];
addElement (extractedList, name);
js["people"][a]["name"] = "Santa Claus {a+1}"
}
peopleList = toJSON(js);
Merry Christmas
'{"people" :[{"name":"Micky","phone":"012345678","birthday":"0101"},{"name":"Mickey","phone":"12345678","birthday":"0202"},{"name":"Michael ","phone":"2345678","birthday":"0303"},{"name":"Micheal","phone":"345678","birthday":"0404"},{"name":"Mike","phone":"567890","birthday":"0505"}]}';
js = fromJSON (peopleList);
len = length (js["people"]);
extractedList = newList ();
for (a in [0 to len - 1])
{
name = js["people"][a]["name"];
addElement (extractedList, name);
js["people"][a]["name"] = "Santa Claus {a+1}"
}
peopleList = toJSON(js);
Merry Christmas
Crude but it works.
Re: Create,Edit,delete and view Json data
Hi all
In this below example json script how can I access all values in one loop?
Task time, Task note, Alert values in one loop.
[
{
"Task time": 1577340000000,
"Task note": "Backup flow",
"Alert": "weekly"
},
{
"Task time": 1577370840000,
"Task note": "Calls logging flow",
"Alert": "daily"
},
{
"Task time": 1577384400000,
"Task note": "Break file flow",
"Alert": "weekly"
},
{
"Task time": 1577424600000,
"Task note": "Filter palm oil",
"Alert": "daily"
},
{
"Task time": 1577925900000,
"Task note": "Make a call to parents",
"Alert": "weekly"
},
{
"Task time": 1592095500000,
"Task note": "happy birthday",
"Alert": "yearly"
},
{
"Task time": 1593478800000,
"Task note": "Happy wedding anniversary",
"Alert": "yearly"
}
]
from record4 thanks a lot
In this below example json script how can I access all values in one loop?
Task time, Task note, Alert values in one loop.
[
{
"Task time": 1577340000000,
"Task note": "Backup flow",
"Alert": "weekly"
},
{
"Task time": 1577370840000,
"Task note": "Calls logging flow",
"Alert": "daily"
},
{
"Task time": 1577384400000,
"Task note": "Break file flow",
"Alert": "weekly"
},
{
"Task time": 1577424600000,
"Task note": "Filter palm oil",
"Alert": "daily"
},
{
"Task time": 1577925900000,
"Task note": "Make a call to parents",
"Alert": "weekly"
},
{
"Task time": 1592095500000,
"Task note": "happy birthday",
"Alert": "yearly"
},
{
"Task time": 1593478800000,
"Task note": "Happy wedding anniversary",
"Alert": "yearly"
}
]
from record4 thanks a lot
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1
Samsung Galaxy j2 non rooted.
Android 5.1.1
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Create,Edit,delete and view Json data
Firstly, I couldn't copy your data. It was giving me formatting problems. I think it's where you laid in a JSON style structure. Using DEBUG DIALOG click on js and view as JSON and you'll see the data below presented in a JSON style structure.
So here it is with just 2 entries.
Hope this helps
extractedList = newList ();
MyTasks =
'{"tasks" :[{"Task time":1577340000000,"Task note":"Backup flow","Alert":"weekly"},{"Task time":1577370840000,"Task note":"Calls logging flow","Alert":"daily"}]}';
js = fromJSON (MyTasks);
len = length (js["tasks"]);
for (i in [0 to len - 1])
{
frequency = js["tasks"]["Alert"];
addElement (extractedList, frequency);
}
So here it is with just 2 entries.
Hope this helps
extractedList = newList ();
MyTasks =
'{"tasks" :[{"Task time":1577340000000,"Task note":"Backup flow","Alert":"weekly"},{"Task time":1577370840000,"Task note":"Calls logging flow","Alert":"daily"}]}';
js = fromJSON (MyTasks);
len = length (js["tasks"]);
for (i in [0 to len - 1])
{
frequency = js["tasks"]["Alert"];
addElement (extractedList, frequency);
}
Crude but it works.
Re: Create,Edit,delete and view Json data
Hi Micky Micky
I want to get all values in one loop not only one.
Alert ,Task time and Task note all values
Thanks from record4
I want to get all values in one loop not only one.
Alert ,Task time and Task note all values
Thanks from record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1
Samsung Galaxy j2 non rooted.
Android 5.1.1
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Create,Edit,delete and view Json data
Just add more queries to the loop.
Also, there was an error in what I posted before.
Which I now see is caused when I paste into this window.
Disable BBCode got rid of the problem.
extractedList = newList ();
MyTasks =
'{"tasks" :[{"Task time":1577340000000,"Task note":"Backup flow","Alert":"weekly"},{"Task time":1577370840000,"Task note":"Calls logging flow","Alert":"daily"}]}';
js = fromJSON (MyTasks);
len = length (js["tasks"]);
for (i in [0 to len - 1])
{
time = js["tasks"][i]["Task time"];
addElement (extractedList, time);
note = js["tasks"][i]["Task note"];
addElement (extractedList, note);
frequency = js["tasks"][i]["Alert"];
addElement (extractedList, frequency);
}
Also, there was an error in what I posted before.
Which I now see is caused when I paste into this window.
Disable BBCode got rid of the problem.
extractedList = newList ();
MyTasks =
'{"tasks" :[{"Task time":1577340000000,"Task note":"Backup flow","Alert":"weekly"},{"Task time":1577370840000,"Task note":"Calls logging flow","Alert":"daily"}]}';
js = fromJSON (MyTasks);
len = length (js["tasks"]);
for (i in [0 to len - 1])
{
time = js["tasks"][i]["Task time"];
addElement (extractedList, time);
note = js["tasks"][i]["Task note"];
addElement (extractedList, note);
frequency = js["tasks"][i]["Alert"];
addElement (extractedList, frequency);
}
Crude but it works.
Re: Create,Edit,delete and view Json data
Hi Micky Micky
Thanks a lot. Where can I learn more information about json ?
From record4
Thanks a lot. Where can I learn more information about json ?
From record4
No.1 Automation app in play store Automagic Premium
Samsung Galaxy j2 non rooted.
Android 5.1.1
Samsung Galaxy j2 non rooted.
Android 5.1.1