#
#学習データコンバートプログラム
#
import json
print('********** JSONファイルを読み込む **********')

# JSONファイルからテキストストリームを生成
with open('codes.json', mode='rt', encoding='utf-8') as file:
  print('file: ' + str(file))

  # 辞書オブジェクト(dictionary)を取得
  data = json.load(file)
  print('data: ' + str(type(data)))

  # JSONデータから必要な箇所を出力
# print('message: ' + data['message'])
  for key in data:

    print(key,"::",data[key])

    for i in range(len(data[key])):
        data[key][i] = int(data[key][i]/2)
#       print(i,"-",data[key][i])
# 辞書オブジェクトをJSONファイルへ出力
with open('codes2.json', mode='wt', encoding='utf-8') as file:
  json.dump(data, file, ensure_ascii=False, indent=2)