Skip to content

JSON-Data won't be processed completely (ignores sub-arrays) #15

@Grauen

Description

@Grauen

Hi there,

I'm parsing data from the youtube API. In this case I got an array of items I'd like to parse:
this is the input for the json_decode

String input for json_decode:

'{
"title": "Dave Gaming",
"description": "Willkommen zu meinem Channel mit der besten Community weit und breit! \n\nHier findet ihr alles, was das Gamerherz begehrt. 20 Jahre alt und seit 17 Jahren leidenschaftlicher Gamer!\n \nGespielt wird alles, was Spaß macht:\n\nAktuell:\n- F1 2015 - GTA ONLINE - League of Legends - MAD MAX - FIFA 16 - Tearaway Unfolded - Forza 6 - SOMA\n\nKommende Let's Plays:\n\n\nOKTOBER:\nUncharted Collection - Assassin's Creed: Syndicate - HALO 5\n\nNOVEMBER:\nNeed for Speed - Call of Duty: Black Ops 3 - Rise of the Tomb Raider - Star Wars: Battlefront 3\n\nDEZEMBER:\nJust Cause 3\n \n \nAuf eine geile gemeinsame Zeit! :)",
"publishedAt": "2014-10-17T21:04:42.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/-80u0cN0eJrY/AAAAAAAAAAI/AAAAAAAAAAA/y5b34eyGCrM/s88-c-k-no/photo.jpg"
},
"medium": {
"url": "https://yt3.ggpht.com/-80u0cN0eJrY/AAAAAAAAAAI/AAAAAAAAAAA/y5b34eyGCrM/s240-c-k-no/photo.jpg"
},
"high": {
"url": "https://yt3.ggpht.com/-80u0cN0eJrY/AAAAAAAAAAI/AAAAAAAAAAA/y5b34eyGCrM/s240-c-k-no/photo.jpg"
}
},
"localized": {
"title": "Dave Gaming",
"description": "Willkommen zu meinem Channel mit der besten Community weit und breit! \n\nHier findet ihr alles, was das Gamerherz begehrt. 20 Jahre alt und seit 17 Jahren leidenschaftlicher Gamer!\n \nGespielt wird alles, was Spaß macht:\n\nAktuell:\n- F1 2015 - GTA ONLINE - League of Legends - MAD MAX - FIFA 16 - Tearaway Unfolded - Forza 6 - SOMA\n\nKommende Let's Plays:\n\n\nOKTOBER:\nUncharted Collection - Assassin's Creed: Syndicate - HALO 5\n\nNOVEMBER:\nNeed for Speed - Call of Duty: Black Ops 3 - Rise of the Tomb Raider - Star Wars: Battlefront 3\n\nDEZEMBER:\nJust Cause 3\n \n \nAuf eine geile gemeinsame Zeit! :"
},
"country": "DE"
}'

output of json_decode():

stdClass Object ( [title] => Dave Gaming [description] => Willkommen zu meinem Channel mit der besten Community weit und breit! Hier findet ihr alles, was das Gamerherz begehrt. 20 Jahre alt und seit 17 Jahren leidenschaftlicher Gamer! Gespielt wird alles, was Spaß macht: Aktuell: - F1 2015 - GTA ONLINE - League of Legends - MAD MAX - FIFA 16 - Tearaway Unfolded - Forza 6 - SOMA Kommende Let's Plays: OKTOBER: Uncharted Collection - Assassin's Creed: Syndicate - HALO 5 NOVEMBER: Need for Speed - Call of Duty: Black Ops 3 - Rise of the Tomb Raider - Star Wars: Battlefront 3 DEZEMBER: Just Cause 3 Auf eine geile gemeinsame Zeit! :) [publishedAt] => 2014-10-17T21:04:42.000Z [thumbnails] => stdClass Object ( [default] => stdClass Object ( [url] => https://yt3.ggpht.com/-80u0cN0eJrY/AAAAAAAAAAI/AAAAAAAAAAA/y5b34eyGCrM/s88-c-k-no/photo.jpg ) [medium] => stdClass Object ( [url] => https://yt3.ggpht.com/-80u0cN0eJrY/AAAAAAAAAAI/AAAAAAAAAAA/y5b34eyGCrM/s240-c-k-no/photo.jpg ) [high] => stdClass Object ( [url] => https://yt3.ggpht.com/-80u0cN0eJrY/AAAAAAAAAAI/AAAAAAAAAAA/y5b34eyGCrM/s240-c-k-no/photo.jpg ) ) [localized] => stdClass Object ( [title] => Dave Gaming [description] => Willkommen zu meinem Channel mit der besten Community weit und breit! Hier findet ihr alles, was das Gamerherz begehrt. 20 Jahre alt und seit 17 Jahren leidenschaftlicher Gamer! Gespielt wird alles, was Spaß macht: Aktuell: - F1 2015 - GTA ONLINE - League of Legends - MAD MAX - FIFA 16 - Tearaway Unfolded - Forza 6 - SOMA Kommende Let's Plays: OKTOBER: Uncharted Collection - Assassin's Creed: Syndicate - HALO 5 NOVEMBER: Need for Speed - Call of Duty: Black Ops 3 - Rise of the Tomb Raider - Star Wars: Battlefront 3 DEZEMBER: Just Cause 3 Auf eine geile gemeinsame Zeit! : ) [country] => DE ) when I call $db->save($obj, "channel");

where will be only the fields:
id
title
description
publishedAt
country

Sub-Elements will currently be ignored without any warning.
It would be great if you could add/insert into another table for each sub element and handle the mapping.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions