import json
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('json_file', nargs='+')
parser.add_argument('output_file')

if __name__ == "__main__":
    args = parser.parse_args()

    list_all = []
    for jf in args.json_file:
        with open(jf) as in_f:
            list_all += json.load(in_f)

    with open(args.output_file, 'w') as out_f:
        json.dump(list_all, out_f)

import json
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('json_file', nargs='+')
parser.add_argument('output_file')

if __name__ == "__main__":
    args = parser.parse_args()

    list_all = []
    for jf in args.json_file:
        with open(jf) as in_f:
            file_jsons = json.load(in_f)
            for fj in file_jsons:
                if fj not in list_all:
                    list_all.append(fj)

    with open(args.output_file, 'w') as out_f:
        json.dump(list_all, out_f)

Remove duplicate JSON gaferences when concatenating
Remove duplicate JSON gaferences when concatenating

  import json
  import argparse
  
  parser = argparse.ArgumentParser()
  parser.add_argument('json_file', nargs='+')
  parser.add_argument('output_file')
  
  if __name__ == "__main__":
      args = parser.parse_args()
  
      list_all = []
      for jf in args.json_file:
          with open(jf) as in_f:
-             list_all += json.load(in_f)
+             file_jsons = json.load(in_f)
+             for fj in file_jsons:
+                 if fj not in list_all:
+                     list_all.append(fj)
  
      with open(args.output_file, 'w') as out_f:
          json.dump(list_all, out_f)
  
Remove duplicate JSON gaferences when concatenating
## Code Before:
import json
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('json_file', nargs='+')
parser.add_argument('output_file')

if __name__ == "__main__":
    args = parser.parse_args()

    list_all = []
    for jf in args.json_file:
        with open(jf) as in_f:
            list_all += json.load(in_f)

    with open(args.output_file, 'w') as out_f:
        json.dump(list_all, out_f)

## Instruction:
Remove duplicate JSON gaferences when concatenating
## Code After:
import json
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('json_file', nargs='+')
parser.add_argument('output_file')

if __name__ == "__main__":
    args = parser.parse_args()

    list_all = []
    for jf in args.json_file:
        with open(jf) as in_f:
            file_jsons = json.load(in_f)
            for fj in file_jsons:
                if fj not in list_all:
                    list_all.append(fj)

    with open(args.output_file, 'w') as out_f:
        json.dump(list_all, out_f)
