我有这样的JSON:https://paste.ubuntu.com/p/HkTK9xTzNx/
如何获取“ imdb_id”字符串(第14行)。没有包含该值的数组,它不在方分支中,所以我不知道如何获取它。
答案 0 :(得分:0)
根据您的需要的解决方案:
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
/**
* @Route("/" , name="homepage")
*/
public function homepage_function()
{
dump("123");
return $this->render("home/index.html.twig", [
] );
}
}
标准解决方案:
try {
imdbLink = response.getString("imdb_id");
} catch (JSONException e) {
e.printStackTrace();
}