A
A
Andrey Grinevich2014-08-14 08:40:27
Python
Andrey Grinevich, 2014-08-14 08:40:27

How to parse json in python?

Good day, there was a need to parse a json file and store its contents in MongoDB using mongo_engine. It will be necessary to do several stages of saving, since the final model has two reference fields, that is, it is necessary to extract data for intermediate saving / processing.
Are there any libraries/others that make this operation easier?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
s1dney, 2014-08-14
@Derfirm

Parsing JSON in python is convenient out of the box.

import json

data = {"1":"one", "2":"two"} # python словарь
json_data = json.dumps(data) # упаковываем
parsed_json = json.loads(json_data) #распаковываем
print data == parsed_json # True

K
Konstantin Dovnar, 2014-08-14
@SolidlSnake

json and what @sim3x wrote

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question