如何在没有JSONArray的情况下获取JSONObject

时间:2020-03-27 16:41:08

标签: android json android-studio

我有这样的JSON:https://paste.ubuntu.com/p/HkTK9xTzNx/

如何获取“ imdb_id”字符串(第14行)。没有包含该值的数组,它不在方分支中,所以我不知道如何获取它。

1 个答案:

答案 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();
 }