import json import time for n in range(1, 10): data = {'id': n, 't': float("%.3f" % time.time()), 'interest':['photo','tt']} json_data=json.dumps(data, indent=4, sort_keys=True) print(json_data)
Output:{
"id": 1,
"interest": [
"photo",
"tt"
],
"t": 1571751206.159
}
{
"id": 2,
"interest": [
"photo",
"tt"
],
"t": 1571751206.159
}
{
"id": 3,
"interest": [
"photo",
"tt"
],
"t": 1571751206.159
}
{
"id": 4,
"interest": [
"photo",
"tt"
],
"t": 1571751206.159
}
{
"id": 5,
"interest": [
"photo",
"tt"
],
"t": 1571751206.159
}
{
"id": 6,
"interest": [
"photo",
"tt"
],
"t": 1571751206.159
}
{
"id": 7,
"interest": [
"photo",
"tt"
],
"t": 1571751206.16
}
{
"id": 8,
"interest": [
"photo",
"tt"
],
"t": 1571751206.16
}
{
"id": 9,
"interest": [
"photo",
"tt"
],
"t": 1571751206.16
}
Note that this prints 9 separate JSON strings, not single JSON string
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs