Mazin
(Mazin Manjeri)
July 15, 2021, 3:15pm
#1
So guys,
I have a problem with converting json to dictionary.
I’m trying to get data from an api (rapidapi google search api ‘image’ method)
I want to get the image link and it’s title
So, Related Blocks below.
Blocks
Also tried this block :
Error
Json Image
These I want
So pls help guys
Mazin
(Mazin Manjeri)
July 15, 2021, 4:08pm
#2
Hello guys, anyone help me
Mazin
(Mazin Manjeri)
July 15, 2021, 4:10pm
#3
The blocks seem good to me, what if you try using @Mohamed_Tamer ’s extension to convert json text to dictionary? I have faced similar cases before where json is decoded wrongly.
The extension:
Json To Dictionary Extension
Release date : 2020-10-24T23:00:00Z (UTC)
Last Update Date : 2020-10-24T23:00:00Z (UTC)
Current Version: 1
Min. Api version : 1 ( Works on every android version )
Ending Date : ( When kodular add it as a built in block )
Description
Hello, every one ! Today i release my very first extension ! Json To Dictionary , i actually made it after seeing this topic : Request for JSON decode to dictionary , to parse json text to dictionaries till kodular …
See my bug report here:
[image]
I want to use this block (from AI2) in Kodular. Although the method of Peter (the above link) worked sometimes, but when it faced array, it is completely wrong.
Check this topic for more information:
1 Like
Have you tried like this,?
organic-result = image_results
title(no change)
replace url with src
create new blocks for image
2 Likes
pavi2410
(Pavitra Golchha)
July 15, 2021, 6:57pm
#6
The issue with your blocks is that you are trying to access “images” key from a list and not a dictionary.
Arrow should point a bit down
1 Like
Mazin
(Mazin Manjeri)
July 16, 2021, 1:44am
#9
1 Like
Kevinkun
(kevinkun)
July 16, 2021, 2:52am
#10
I think there is a bug for “walk all at level” block.
You can do like this:
I found two problems.
The doesn’t convert json to dictionary correctly.
The sample json i made:
{
"image_result": [
{
"image":{
"src":"https://google.com",
"alt":""
},
"link":{
"href":"https://google.com/href",
"title":"hello",
"domain":"google.com"
}
},
{
"image":{
"src":"https://google.com",
"alt":""
},
"link":{
"href":"https://google.com/href",
"title":"hello",
"domain":"google.com"
}
},
{
"image":{
"src":"https://google.com",
"alt":""
},
"link":{
"href":"https://google.com/href",
"title":"hello",
"domain":"google.com"
}
},
{
"image":{
"src":"https://google.com",
"alt":""
},
"link":{
"href":"https://google.com/href",
"title":"hello",
"domain":"google.com"
}
}
]
}
The converted result:
You need to use the JsonToDictionary extension for now.
WatermelonIce:
The extension:
After correctly converting, I found that adding one more “walk all at level” to the list actually works.
system
(system)
Closed
August 15, 2021, 3:09pm
#12
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.