Page 1 of 3
Create,Edit,delete and view Json data
Posted: 24 Dec 2019 03:21
by Rafi4
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
Re: Create,Edit,delete and view Json data
Posted: 24 Dec 2019 18:19
by Desmanto
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.
Re: Create,Edit,delete and view Json data
Posted: 24 Dec 2019 19:05
by Micky Micky
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
Re: Create,Edit,delete and view Json data
Posted: 25 Dec 2019 01:56
by Rafi4
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
Re: Create,Edit,delete and view Json data
Posted: 25 Dec 2019 06:07
by Micky Micky
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
Re: Create,Edit,delete and view Json data
Posted: 26 Dec 2019 05:50
by Rafi4
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
Re: Create,Edit,delete and view Json data
Posted: 26 Dec 2019 07:19
by Micky Micky
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);
}
Re: Create,Edit,delete and view Json data
Posted: 26 Dec 2019 10:35
by Rafi4
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
Re: Create,Edit,delete and view Json data
Posted: 26 Dec 2019 11:34
by Micky Micky
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);
}
Re: Create,Edit,delete and view Json data
Posted: 26 Dec 2019 14:07
by Rafi4
Hi Micky Micky
Thanks a lot. Where can I learn more information about json ?
From record4