I am rewritting function to get data from Json file to mysql. I have a bug in my code and I don't know where. If you can looking to function and tell me where do I do something wrong, I will be very happy.
json:
[{
"title":"Dumb Ways to Die 3 World Tour","gameType":"html5","description":"Play mini games featuring the characters from Dumb Ways to Die.
Dumb Ways to Die is a worldwide brand with over 300 million downloads on Apple App Store and Google Play combined.
Test your reflexes in this challenging series of mini games, where a milisecond can make the difference between winning and losing.
Score coins for each challenge, and use the to repair the once great town of Dumbville.",
"instructions":"Play mini games featuring the characters from Dumb Ways to Die.",
"url":"https://zxxcom/a91f360648334bc988222f1aff557c4e/",
"width":540,
"height":960,
"assetList":[{"name":"https://zxxcom/a91f360648334bc988222f1aff557c4e-512x340.jpeg"},{"name":"https://zxx.com/a91f360648334bc988222f1aff557c4e-512x512.jpeg"},{"name":"https://zxx.com/a91f360648334bc988222f1aff557c4e-512x384.jpeg"},{"name":"https://zxx.com/a91f360648334bc988222f1aff557c4e-1280x720.jpeg"},{"name":"https://zxx.com/a91f360648334bc988222f1aff557c4e-1280x550.jpeg"}],
"categoryList":[{"name":"Arcade"},{"name":"Sports"}],
"tagList":[{"name":"box2d"},{"name":"brain"},{"name":"brand"} ,{"name":"cute"},{"name":"endless"},{"name":"physi cs"},{"name":"simulation"},{"name":"cognitive"}],
"bundleList":[]},
code:
public function getParameterMap()
{
return [
'file' => 'url',
'category' => ['categoryList']['name'],
'thumbnail' => ['assetList']['name'],
'tags' => ['tagList']['name'],
'name' => 'title'
];
}
/**
* @param FeedGame $game
* @param $feedData
* @return mixed
*/
public function filterGame(FeedGame $game, $feedData)
{
$game->setProviderId(substr(md5($feedData->name), 0, 5));
$game->setCategory(array([($feedData->categoryList->name)]));
$game->setThumbnail(array([($feedData->assetList->name)]));
$name = $feedData->title;
$description = $feedData->description;
$game->setTags(array([($feedData->tagList->name)]));
}
After add data to mysql - in my base I see in category column – "Array". In tags column and thumbnail column, I see "Array" too.
In function filterGame - here I have something wrong, and I don't know, how to write it. Json file has array in array, and I don't know how to appeal to it.
Can you help me with this?
I want to have in mysql - thumbnail 512x512 and first category from categoryList (json), and all list of tags, with " , " after each tag.
Ps - sorry for my english - I learned it myself, and probably I do a lot of mistakes.
var_dump:
array (
0 =>
array (
'title' => 'Dumb Ways to Die 3 World Tour',
'gameType' => 'html5',
'description' => 'Play mini games featuring the characters from Dumb Ways to Die.
Dumb Ways to Die is a worldwide brand with over 300 million downloads on Apple App Store and Google Play combined.
Test your reflexes in this challenging series of mini games, where a milisecond can make the difference between winning and losing.
Score coins for each challenge, and use the to repair the once great town of Dumbville.',
'instructions' => 'Play mini games featuring the characters from Dumb Ways to Die.',
'url' => 'https://zxx.com/a91f360648334bc988222f1aff557c4e/',
'width' => 540,
'height' => 960,
'assetList' =>
array (
0 =>
array (
'name' => 'https://zxx.com/a91f360648334bc988222f1aff557c4e-512x340.jpeg',
),
1 =>
array (
'name' => 'https://zxx.com/a91f360648334bc988222f1aff557c4e-512x512.jpeg',
),
2 =>
array (
'name' => 'https://zxx.com/a91f360648334bc988222f1aff557c4e-512x384.jpeg',
),
3 =>
array (
'name' => 'https://zxx.com/a91f360648334bc988222f1aff557c4e-1280x720.jpeg',
),
4 =>
array (
'name' => 'https://zxx.com/a91f360648334bc988222f1aff557c4e-1280x550.jpeg',
),
),
'categoryList' =>
array (
0 =>
array (
'name' => 'Arcade',
),
1 =>
array (
'name' => 'Sports',
),
),
'tagList' =>
array (
0 =>
array (
'name' => 'box2d',
),
1 =>
array (
'name' => 'brain',
),
2 =>
array (
'name' => 'brand',
),
3 =>
array (
'name' => 'cute',
),
4 =>
array (
'name' => 'endless',
),
5 =>
array (
'name' => 'physics',
),
6 =>
array (
'name' => 'simulation',
),
7 =>
array (
'name' => 'cognitive',
),
),
'bundleList' =>
array (
),
),
1 =>
array (
'title' => 'HeX PuzzleGuys',
'gameType' => 'html5',
'description' => 'Connect 4 hexagons of the same color, it\'s that simple!',
'instructions' => 'Drag and drop pieces and connect at least 4 hexagons of the same color. When you get out of space, the game is over (luckily, you can always restart it!)',
'url' => 'https://zxx.com/657afaed169b45b6a678637be1912c65/',
'width' => 800,
'height' => 600,
'assetList' =>
array (
0 =>
array (
'name' => 'https://zxx.com/657afaed169b45b6a678637be1912c65-512x384.jpeg',
),
1 =>
array (
'name' => 'https://zxx.com/657afaed169b45b6a678637be1912c65-512x512.jpeg',
),
2 =>
array (
'name' => 'https://zxx.com/657afaed169b45b6a678637be1912c65-512x340.jpeg',
),
),
'categoryList' =>
array (
0 =>
array (
'name' => 'Puzzle',
),
),
'tagList' =>
array (
0 =>
array (
'name' => 'hexagon',
),
1 =>
array (
'name' => 'connect-4',
),
),
'bundleList' =>
array (
),
),
)