title: Best way to parse JSON log file with python/bash?
body: <p>Currently, I have a python program which calls a bash script to parse through this log file that CONTAINS json data, but each line has non-json data on it as well. For example, every line has this format with a different JSON:</p>
  
  <pre><code>&lt;123&gt;1 2017-01-23T10:53:56.111-11:12 blaa blaa '{"jsondata": "1.0", "result": 1, "id": 1234}'
  </code></pre>
  
  <p>My goal is to count the number of times this message occurred, possibly the number of times another message occurred in the line after this, and make sure it's formatted correctly.</p>
  
  <p>I have been using a bash script, grepping regular expressions that are formatted to the correct format. So the problem is that JSON fields may come in out of order, so my regex wouldn't work. For example the above line may come in as:</p>
  
  <pre><code>&lt;123&gt;1 2017-01-23T10:53:56.111-11:12 blaa blaa '{"jsondata": "1.0","id": 1234, "result": 1}'
  </code></pre>
  
  <p>I can also do it in python with json decoder but since this log file is not a true JSON file, I don't think that would work. What's the best but simplest way to do this? Preferably with python or some command line scripting. I'm in Ubuntu 16.04.</p>
  
  <p>My expected input is a log file with lines that are the same as above. My expected output is to be able to check how many lines are formatted as above, with the same keys in any order, and different values, as well as check how many times that specific json message occurred (there are different json messages on each line), even if the JSON keys are not in the same order.</p>