To make a Python 2D list into a json file

Asked 2 years ago, Updated 2 years ago, 43 views

It's been 3 days since I studied Python. There's a lot I don't know. I want to make a sawtooth 2D list into Json, so how should I do it?

[
    ['900', '196', '196', '192', '57'], 
    ["After 1 Minute", "After 12 Minutes", "After 15 Minutes", "After 16 Minutes", "13:40", 
    ["Ganada", "Lulu", "Cider", "Coke"]
]

python json

2022-09-22 18:15

2 Answers

Not through any structuralization

If you want to make the data structure purely json format...

import json
list = ['900', '196', '196', '192', '57'], ['1 minute later', '12 minutes later', '15 minutes later', '16 minutes later', '13:40'], ['Ganada', 'Lulu', 'Cider', 'Cola']]

# # encode
json_str = json.dumps(list)

# # decode
# # json.loads(json_str)


2022-09-22 18:15

Within the given list...

To give you a serious answer, it's not clear under what conditions and by what rules the material should be made into json, so No json can make it.


2022-09-22 18:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.