reader_from_json/reader_from_JSON.py
2017-07-03 11:39:25 +02:00

18 lines
483 B
Python

import json
from random import choice
from sys import argv
from collections import OrderedDict
def generate_from_json(text):
with open(text) as data_file:
out_list = []
data = json.load(data_file, object_pairs_hook=OrderedDict)
out_string = " ".join(choice(data[keys])for keys in data)
return out_string
if __name__ == '__main__':
if argv[1:]:
print(generate_from_json(argv[1]))
else:
print('Usage:', argv[0], 'something_antani.json')