title: Sum JSON objects and get a JSON file in Python
body: <p>I have a JSON file with many objects. I want to filter it to discard all the objects that does not have a specific field called ´id´. I developed a piece of code but it does not work:</p>
  
  <pre><code>import json
  b=open("all.json","r")
  sytems_objs=json.loads(b.read())
  flag=0
  for i in range(len(sytems_objs)):
      if sytems_objs[i]["id"]&lt;&gt;None:
          if flag==0:
              total=sytems_objs[i]
              flag=1
          else:
              total=total+sytems_objs[i]
  
  file1=open("filtered.json","w+")
  json.dump(total, file1)
  
  c=open("filtered.json","r")
  sytems_objs2=json.loads(b.read())
  </code></pre>
  
  <p>I get a Error: <code>ValueError: No JSON object could be decoded</code></p>
  
  <p>What am I doing wrong?</p>