B
B
beduin012018-05-16 13:15:59
Python
beduin01, 2018-05-16 13:15:59

What is the correct way to insert values ​​into JSON?

There is a very long JSON part of the key-values ​​from which I now take from somewhere outside and just paste everything in the manner:
"data":{"client_id":' + config['client_id'] + '
When there are a lot of values, it becomes inconvenient to use. Maybe there are some better options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-05-16
@beduin01

Obviously, you need to use the json module specially designed for this , which is included in the standard library:

import json

json_str = json.dumps({ 'data': config })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question