title: JSON annotations error "string indices must be integers"
body: <p>Wrote a function to parse COCO JSON. How to solve error?
  a sample file_name here is : hard_hat_workers2819_png.rf.6870e9b0e6f5cd67d581d9d6185124e6.jpg
  The name of the file can't be changed as the dataset is huge. What should I do?</p>
  <p>[enter image description here][1]</p>
  <pre><code>def get_board_dicts(imgdir):
      json_file = imgdir+&quot;/_annotations.coco.json&quot; #Fetch the json file
      with open(json_file) as f:
          dataset_dicts = json.load(f) #loads(jsonStr)
      for i in dataset_dicts:
          filename = i['file_name'] 
          i['file_name'] = imgdir+&quot;/&quot;+filename 
          for j in i[&quot;annotations&quot;]:
              j[&quot;bbox_mode&quot;] = BoxMode.XYWH_ABS #Setting the required Box Mode
              j[&quot;category_id&quot;] = int(j[&quot;category_id&quot;])
      return dataset_dicts 
  
  
  ---------------------------------------------------------------------------
  
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-21-3c960c9b4cee&gt; in &lt;module&gt;()
        1 #Visualizing the Train Dataset
  ----&gt; 2 dataset_dicts = get_board_dicts(&quot;HardHat_COCO/train&quot;)
        3 #Randomly choosing 3 images from the Set
        4 for d in random.sample(dataset_dicts, 3):
        5     img = cv2.imread(d[&quot;file_name&quot;])
  
  &lt;ipython-input-20-a32bcb391fe9&gt; in get_board_dicts(imgdir)
        7         dataset_dicts = json.load(f) #loads(jsonStr)
        8     for i in dataset_dicts:
  ----&gt; 9         filename = i['file_name']
       10         i['file_name'] = imgdir+&quot;/&quot;+filename
       11         for j in i[&quot;annotations&quot;]:
  
  TypeError: string indices must be integers 
  
  
    #samples from COCO JSON file:
  &quot;images&quot;: [
          {
              &quot;id&quot;: 0,
              &quot;license&quot;: 1,
              &quot;file_name&quot;: &quot;hard_hat_workers2819_png.rf.6870e9b0e6f5cd67d581d9d6185124e6.jpg&quot;,
              &quot;height&quot;: 416,
              &quot;width&quot;: 416,
              &quot;date_captured&quot;: &quot;2021-08-31T14:27:07+00:00&quot;
          },
          {
              &quot;id&quot;: 1,
              &quot;license&quot;: 1,
              &quot;file_name&quot;: &quot;hard_hat_workers239_png.rf.68144af0d963cc745832ccbf69cd93ec.jpg&quot;,
              &quot;height&quot;: 416,
              &quot;width&quot;: 416,
              &quot;date_captured&quot;: &quot;2021-08-31T14:27:07+00:00&quot;
          },
  </code></pre>