Create,Edit,delete and view Json data
Moderator: Martin
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Create,Edit,delete and view Json data
I used trial and error.
The problem is always deciphering the structure that the author used.
For example, this API's response to a HTTP REQUEST was bewildering. I wanted the line name and status. e.g. Bakerloo - Severe Delays
https://api.tfl.gov.uk/line/mode/tube,o ... ail/status
Whereas this API response was easy:
https://official-joke-api.appspot.com/random_joke
I'm using JSON more and more now instead of simple lists as it seems for flexible. I'm happy to help but I'm still learning too.
Good luck
The problem is always deciphering the structure that the author used.
For example, this API's response to a HTTP REQUEST was bewildering. I wanted the line name and status. e.g. Bakerloo - Severe Delays
https://api.tfl.gov.uk/line/mode/tube,o ... ail/status
Whereas this API response was easy:
https://official-joke-api.appspot.com/random_joke
I'm using JSON more and more now instead of simple lists as it seems for flexible. I'm happy to help but I'm still learning too.
Good luck
Crude but it works.
Re: Create,Edit,delete and view Json data
You don't have to do trial and error. When using debug dialog, you can always browse to the converted JSON, as shown in here : viewtopic.php?f=5&t=8429&p=26494&hilit=json#p26501
Just check if it is a map, then use the key. If it is list, use numbering shown. Debug dialog is one of the best feature to help us creating the flow.
Just check if it is a map, then use the key. If it is list, use numbering shown. Debug dialog is one of the best feature to help us creating the flow.
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
Yes, trial and error using DEBUG DIALOG. Without that it's impossible. Thanks for highlighting that.
Whilst you're here, I found it impossible to add to a JSON object. For example, adding another entry to the tasks example above. Any help would be appreciated.
Edit:
IT'S OKAY, I FOUND THE ANSWER ON THE FORUM. SOMEONE CALLED DESMANTO EXPLAINED IT PERFECTLY!
Many thanks
Whilst you're here, I found it impossible to add to a JSON object. For example, adding another entry to the tasks example above. Any help would be appreciated.
Edit:
IT'S OKAY, I FOUND THE ANSWER ON THE FORUM. SOMEONE CALLED DESMANTO EXPLAINED IT PERFECTLY!
Many thanks
Last edited by Micky Micky on 29 Dec 2019 14:42, edited 1 time in total.
Crude but it works.
Re: Create,Edit,delete and view Json data
Hi Micky Micky
In this below example I want to get elements
which contains "Alert":"weekly".
Is this possible? If yes how can I?
[
{
"Task time": 1577384400000,
"Task note": "Break file flow",
"Alert": "weekly"
},
{
"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"
}
]
Thanks from record4
In this below example I want to get elements
which contains "Alert":"weekly".
Is this possible? If yes how can I?
[
{
"Task time": 1577384400000,
"Task note": "Break file flow",
"Alert": "weekly"
},
{
"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"
}
]
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
Code: Select all
tasksList = '{"tasks":[{"Task time":1577384400000,"Task note":"Break file flow","Alert":"weekly"},{"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"}]}';
extractedList = newList ();
js = fromJSON (tasksList);
len = length (js["tasks"]);
search = "weekly";
for (i in [0 to len - 1])
{
alert = js["tasks"][i]["Alert"];
if (matches (search, alert))
{
addElement (extractedList, js["tasks"][i]["Task time"]);
addElement (extractedList, js["tasks"][i]["Task note"]);
}
};
Crude but it works.
Re: Create,Edit,delete and view Json data
@Micky : Oh, I thought you use bruteforce to find the key
Do you mean to add another list/map to the json? I would convert the json to map/list first, add the map/list to the correct path and then convert it back to JSON. But it seems you have found my other post then.
Do you mean to add another list/map to the json? I would convert the json to map/list first, add the map/list to the correct path and then convert it back to JSON. But it seems you have found my other post then.
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
Yeah, even with DEBUG DIALOG I was still a bit brutal in my ways.
I found that post and it's working great.
I've got a lot of 'crude' to change now!
Thanks very much.
I found that post and it's working great.
I've got a lot of 'crude' to change now!
Thanks very much.
Crude but it works.
Re: Create,Edit,delete and view Json data
Hi Micky Micky
Working Amazing. Thanks a lot.
Happy new year to Martin and all from record4
Working Amazing. Thanks a lot.
Happy new year to Martin and all 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
Hi Micky Micky and all
How can I get contact name using action
Init Variables Contact Info: Name {phone_number} in json format {contact_info,jsonformat}
thanks from record4
How can I get contact name using action
Init Variables Contact Info: Name {phone_number} in json format {contact_info,jsonformat}
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
I used this:
I'm going to post a link to a forum post by Desmanto that explains creating and editing your own JSON objects. It's helped me a lot. I think it will be helpful for you.
It returned 'contact_info' which is already a JSON object. The name was in three places. I think the first one is all you need.
Code: Select all
displayName = contact_info["display_name"];
a = contact_info["structured_name_list"][0]["display_name"];
b = contact_info["structured_name_list"][0]["given_name"];
Crude but it works.