python - How to append JSON objects to a list? -
i'm trying append json objects form list of json objects.
def genindentifier(options): data=json.dumps([identifier,hex_dig]) return data
the data here valid json object follows:
["27780741708467800000001", "e5073922dbb7a278769d52277d49c6ad3017b1ba"]
afterwards, loop through genidentifier function generate many json objects:
data=[] in range(0,2,1): ... data.append(genindentifier(options)) print data
now list of json data not valid json format because of single quotations marks pop up:
['["27780741708467800000000", "f798d2cd9aec1b98fb48b34fd249fe19c06a4a1d"]', '["27780741708467800000001", "e5073922dbb7a278769d52277d49c6ad3017b1ba"]']
any idea how solve that? i've searched , googled in vain.
the trouble dumping data json inside genindentifier, appending json string list.
instead should move json conversion out of function, , @ end:
def genindentifier(options): data = [identifier, hex_dig] return data data = [] in range(0, 2, 1): ... data.append(genindentifier(options)) data = json.dumps(data) print data
Comments
Post a Comment