title: Better way of merging two json strings in Python for ansible callback_plugin
body: <p>I'm writing an plugin to return log results as a json file for ansible-playbook.</p>
  
  <p>I'm not super familiar with python, but I've hacked something together that seems to work:</p>
  
  <pre><code>def json_log(res, host):
      if type(res) == type(dict()):
          if 'verbose_override' not in res:
            host_json = JSONEncoder().encode({'host':host})
            result_json = JSONEncoder().encode(res)
            combined_json = host_json + result_json
            combined_json = combined_json.replace("}{", ',')
            print(combined_json)
  </code></pre>
  
  <p><code>host_json</code> would be something like: <code>{"host": "centos65"}</code></p>
  
  <p><code>result_json</code> would be something like: <code>{"cmd": "echo \"Hello World\" ", "end": "2014-08-01 19:32:38.714584", "stdout": "Hello World", "changed": true, "start": "2014-08-01 19:32:38.707510", "delta": "0:00:00.007074", "stderr": "", "rc": 0, "invocation": {"module_name": "shell", "module_args": "echo \"Hello World\""}}</code></p>
  
  <p>So I've gone for the brute-force route and just combined the strings and removed the <code>}{</code> it gets where they join, so it will be in the format I want as valid json: </p>
  
  <p><code>{"host": "centos65","cmd": "echo \"Hello World\" ", "end": "2014-08-01 19:32:38.714584", "stdout": "Hello World", "changed": true, "start": "2014-08-01 19:32:38.707510", "delta": "0:00:00.007074", "stderr": "", "rc": 0, "invocation": {"module_name": "shell", "module_args": "echo \"Hello World\""}}</code></p>
  
  <p>So right now I'm just mashing together the two strings and then replacing the join with a comma, is there a smarter way to combine them with the host part being at the start of the json?</p>