I'm making a plugin that gets data from an external server through an encoded URL. To decode the output of the plugin I am using a JsonDecode, but it comes back 'NULL'everytime.
The code:
$json = file_get_contents($goodurl);
$data = json_decode($json);
var_dump($data);
This is the response when requesting the URL:
{
"schemaVersion": "1.0",
"catalogueVersion": "4.0.5651.20898",
"encoding": "UTF-8",
"action": "info",
"query": "catalogue",
"success": "true",
"response": {
"title": "Presentations 2Go",
"description": "Presentations2Go videoserver is an innovative solution to simply capture presentations and\/or lectures on video. The video image of the presenter is linked with the presentation and stored for later (re)use.",
"logoUrl": "https:\/\/DEMO-FORMS.presentations2go.eu\/P2G\/images\/logo\/logo.png",
"languages": [
{"lang": "en"},
{"lang": "nl"},
{"lang": "de"},
{"lang": "fr"},
{"lang": "kr"},
{"lang": "no"},
{"lang": "pt"},
{"lang": "dk"},
{"lang": "cn"},
{"lang": "ar"},
{"lang": "se"},
{"lang": "it"},
{"lang": "es"},
{"lang": "ru"},
{"lang": "cy"},
{"lang": "tw"}
],
"videoCount": "380",
"webmaster": "support@presentations2go.eu"
}
}
And this is the output in JSON:
object(stdClass)#83 (7) {
["schemaVersion"]=> string(3) "1.0"
["catalogueVersion"]=> string(14) "4.0.5651.20898"
["encoding"]=> string(5) "UTF-8"
["action"]=> string(4) "info"
["query"]=> string(9) "catalogue"
["success"]=> string(4) "true"
["response"]=> object(stdClass)#84 (6) {
["title"]=> string(17) "Presentations 2Go"
["description"]=> string(207) "Presentations2Go videoserver is an innovative solution to simply capture presentations and/or lectures on video. The video image of the presenter is linked with the presentation and stored for later (re)use."
["logoUrl"]=> string(63) "https://DEMO-FORMS.presentations2go.eu/P2G/images/logo/logo.png"
["languages"]=> array(16) {
[0]=> object(stdClass)#85 (1) {
["lang"]=> string(2) "en"
}
[1]=> object(stdClass)#86 (1) {
["lang"]=> string(2) "nl"
}
[2]=> object(stdClass)#87 (1) {
["lang"]=> string(2) "de"
}
[3]=> object(stdClass)#88 (1) {
["lang"]=> string(2) "fr"
}
[4]=> object(stdClass)#89 (1) {
["lang"]=> string(2) "kr"
}
[5]=> object(stdClass)#90 (1) {
["lang"]=> string(2) "no"
}
[6]=> object(stdClass)#91 (1) {
["lang"]=> string(2) "pt"
}
[7]=> object(stdClass)#92 (1) {
["lang"]=> string(2) "dk"
}
[8]=> object(stdClass)#93 (1) {
["lang"]=> string(2) "cn"
}
[9]=> object(stdClass)#94 (1) {
["lang"]=> string(2) "ar"
}
[10]=> object(stdClass)#95 (1) {
["lang"]=> string(2) "se"
}
[11]=> object(stdClass)#96 (1) {
["lang"]=> string(2) "it"
}
[12]=> object(stdClass)#97 (1) {
["lang"]=> string(2) "es"
}
[13]=> object(stdClass)#98 (1) {
["lang"]=> string(2) "ru"
}
[14]=> object(stdClass)#99 (1) {
["lang"]=> string(2) "cy"
}
[15]=> object(stdClass)#100 (1) {
["lang"]=> string(2) "tw"
}
}
["videoCount"]=> string(3) "378"
["webmaster"]=> string(27) "support@presentations2go.eu"
}
}
I'm not that experienced JSON so I suspect there might be a syntax error in there. But I'm not sure what and how to solve it.