title: How to merge multiple json files into one file in python
body: <p>I want to merge multiple json files into one file in python. The thing that I want to do is if there are several .json files like:</p>
  
  <pre><code># temp1.json
  [{'num':'1', 'item':'smartphone','data':'2019-01-01'},
  {'num':'2', 'item':'smartphone','data':'2019-01-02'},
  {'num':'3', 'item':'smartphone','data':'2019-01-03'},
  {'num':'4', 'item':'smartphone','data':'2019-01-04'}]
  
  # temp2.json
  [{'num':'5', 'item':'smartphone','data':'2019-01-05'},
  {'num':'6', 'item':'smartphone','data':'2019-01-06'},
  {'num':'7', 'item':'smartphone','data':'2019-01-07'}]
  
  # temp3.json
  [{'num':'8', 'item':'smartphone','data':'2019-01-08'},
  {'num':'9', 'item':'smartphone','data':'2019-01-09'},
  {'num':'10', 'item':'smartphone','data':'2019-01-10'},
  {'num':'11', 'item':'smartphone','data':'2019-01-11'},
  {'num':'12', 'item':'smartphone','data':'2019-01-12'}]
  </code></pre>
  
  <p>The result.json files I want to get should look like:</p>
  
  <pre><code># result.json
  [{'num':'1', 'item':'smartphone','data':'2019-01-01'},
  {'num':'2', 'item':'smartphone','data':'2019-01-02'},
  {'num':'3', 'item':'smartphone','data':'2019-01-03'},
  {'num':'4', 'item':'smartphone','data':'2019-01-04'},
  {'num':'5', 'item':'smartphone','data':'2019-01-05'},
  {'num':'6', 'item':'smartphone','data':'2019-01-06'},
  {'num':'7', 'item':'smartphone','data':'2019-01-07'},
  {'num':'8', 'item':'smartphone','data':'2019-01-08'},
  {'num':'9', 'item':'smartphone','data':'2019-01-09'},
  {'num':'10', 'item':'smartphone','data':'2019-01-10'},
  {'num':'11', 'item':'smartphone','data':'2019-01-11'},
  {'num':'12', 'item':'smartphone','data':'2019-01-12'}]
  </code></pre>
  
  <p>The result.json files I got is:</p>
  
  <pre><code># result.json
  [[{'num':'1', 'item':'smartphone','data':'2019-01-01'},
  {'num':'2', 'item':'smartphone','data':'2019-01-02'},
  {'num':'3', 'item':'smartphone','data':'2019-01-03'},
  {'num':'4', 'item':'smartphone','data':'2019-01-04'}],
  [{'num':'5', 'item':'smartphone','data':'2019-01-05'},
  {'num':'6', 'item':'smartphone','data':'2019-01-06'},
  {'num':'7', 'item':'smartphone','data':'2019-01-07'}],
  [{'num':'8', 'item':'smartphone','data':'2019-01-08'},
  {'num':'9', 'item':'smartphone','data':'2019-01-09'},
  {'num':'10', 'item':'smartphone','data':'2019-01-10'},
  {'num':'11', 'item':'smartphone','data':'2019-01-11'},
  {'num':'12', 'item':'smartphone','data':'2019-01-12'}]]
  </code></pre>
  
  <p>I used the code to merge .json files from <a href="https://stackoverflow.com/questions/51056427/concating-merging-of-each-json-files-python">here</a> and changed it very slightly like below:</p>
  
  <pre><code>files=['my.json','files.json',...,'name.json']
  
  def merge_JsonFiles(filename):
      result = list()
      for f1 in filename:
          with open(f1, 'r') as infile:
              result.append(json.load(infile))
  
      with open('counseling3.json', 'w') as output_file:
          json.dump(result, output_file)
  
  merge_JsonFiles(files)
  </code></pre>
  
  <p>I already read several related questions, but there is no answer I need. Can anyone help me?</p>