title: Python, how to build a new Json object from another one
body: <p>I've got a Json object with around 10 elements in it. I just need 4 of the 10 elements and would like to place the 4 elements in a new Json object. I tried different ways, but only get errors. My last code:</p>
  
  <pre><code>import json
  from pprint import pprint
  import time
  import datetime
  
  def update_handler(client, update, users, chats):
      #print(update)
      message = str(update)
      data = json.loads(message)
      if data["_"] == "types.UpdateNewMessage":
          from_id = data["message"]["from_id"]
          if from_id == 390189088:
              #output message to screen
              print ("message id: ", data["message"]["id"])
              print ("date/time: ", data["message"]["date"])
              print ("from: ", data["message"]["from_id"])
              print ("message: ", data["message"]["message"])
              print ("**************")
              #output partial message to file
              json_data = {["message"]["id"],["message"]["date"],["message"]["from_id"],["message"]["message"]}
              with open('chartguysalerts.txt', 'a') as outfile:
                  json.dump(json_data, outfile)
  </code></pre>
  
  <p>The last line of that function gives me error: TypeError: list indices must be integers or slices, not str</p>
  
  <p>I can refer to each element separately so they are valid, the output to screen works fine for example. But i don't know how to put them together in a new shorter Json to output to a file.</p>