title: How do I query GCP log viewer and obtain json results in Python 3.x (like gcloud logging read)
body: <p>I'm building a tool to download GCP logs, save the logs to disk as single line json entries, then perform processing against those logs. The program needs to support both logs exported to cloud storage and logs currently in stackdriver (to partially support environments where exports to cloud storage hasn't been pre-configured). The cloud storage piece is done, but I'm having difficulty with downloading logs from stackdriver.</p>
  
  <p>I would like to implement similar functionality to the <code>gcloud</code> function 'gcloud logging read' in Python. Yes, I could use <code>gcloud</code>, however I would like to build everything into the one tool.</p>
  
  <p>I currently have this sample code to print the result of hits, however I can't get the full log entry in JSON format:</p>
  
  <pre><code>def downloadStackdriver():
      client = logging.Client()
      FILTER = "resource.type=project"
      for entry in client.list_entries(filter_=FILTER):
          a = (entry.payload.value)
          print(a)
  </code></pre>
  
  <p>How can I obtain full JSON output of matching logs like it works using <code>gcloud logging read</code>?</p>
  
  <p>Based on other stackoverflow pages, I've attempted to use MessageToDict and MessageToJson, however I receive the error </p>
  
  <blockquote>
    <p><code>"AttributeError: 'ProtobufEntry' object has no attribute 'DESCRIPTOR'"</code></p>
  </blockquote>