title: How to read the json file of a dynamical way in relation to their size structure
body: <p>I have the following JSON file named <code>ProcessedMetrics.json</code> which is necessary read for send their values to some template:</p>
  
  <pre><code>     {
    "paciente": {
      "id": 1234,
      "nombre": "Pablo Andrés Agudelo Marenco",
      "sesion": {
        "id": 12345,
        "juego": [
          {
            "nombre": "bonzo",
            "nivel": [
              {
                "id": 1234,
                "nombre": "caida libre",
                "segmento": [
                  {
                    "id": 12345,
                    "nombre": "Hombro",
                    "movimiento": [
                      {
                        "id": 1234,
                        "nombre": "flexion",
                        "metricas": [
                          {
                            "min": 12,
                            "max": 34,
                            "media": 23,
                            "moda": 20
                          }
                        ]
                      }
                    ]
                  }
                ],
                "___léeme___": "El array 'iteraciones' contiene las vitorias o derrotas con el tiempo en segundos de cada iteración",
                "iteraciones": [
                  {
                    "victoria": true,
                    "tiempo": 120
                  },
                  {
                    "victoria": false,
                    "tiempo": 232
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  }
  </code></pre>
  
  <p>Through of the following class based view I am reading a JSON file. </p>
  
  <pre><code>class RehabilitationSessionDetail(LoginRequiredMixin,DetailView):
      model = RehabilitationSession
      template_name = 'rehabilitationsession_detail.html'
  
      def get_context_data(self, **kwargs):
          context=super(RehabilitationSessionDetail, self).get_context_data(**kwargs)
          is_auth=False
  
          user = self.request.user
          if user.is_authenticated():
              is_auth=True
  
              with open('ProcessedMetrics.json') as data_file:
                  session_data=json.loads(data_file.read())
  
              #Sending a data to template
                         context.update({'is_auth':is_auth,
                                         'session_data':session_data
                                       })
         return context
  </code></pre>
  
  <p>In my template <code>rehabilitationsession_detail.html</code> I put my tag of this way:</p>
  
  <pre><code>&lt;td&gt;{{session_data.paciente.sesion.juego}}&lt;/td&gt; 
  </code></pre>
  
  <p>Then I get the document json in my template</p>
  
  <p><a href="https://i.stack.imgur.com/SLZB2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SLZB2.png" alt="enter image description here"></a></p>
  
  <p>In my template, I want get the dictionary(before json document) values of a separate way such as follow:</p>
  
  <p><a href="https://i.stack.imgur.com/MsyHT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MsyHT.png" alt="enter image description here"></a></p>
  
  <p>The idea is that without matter the nested levels of the json document I can get the values. Sometimes, the json document will have more identation levels in their structure and other times will be a json document more simple</p>
  
  <p>I would that independently of the json document size (if this have more than one item in your arrays) will be possible read and get all the values.</p>
  
  <p>I  try accessing to the specific item from the <code>RehabilitationSessionDetail</code> view of this way:</p>
  
  <pre><code>segment = data["paciente"]["sesion"]["juego"][0]["nivel"][0]["segmento"][0]["nombre"]
  </code></pre>
  
  <p>And this works, but not always I will get the same json document structure.</p>
  
  <p>In summary, How to can I get the values (nested and parents) of my json document for send them to the template? </p>
  
  <p>I hope can be clear in my question. Any orientation is highly graceful</p>