Answer the question
In order to leave comments, you need to log in
How to display the required variable from JSON?
Good evening!
Can you please tell me how to extract the required variable from json?
Python script using api qiwi on request displays a json report received from qiwi. Its content is as follows:
{
"accounts": [
{
"alias": "string",
"balance": {
"amount": 0,
"currency": 0
},
"bankAlias": "string",
"currency": 0,
"defaultAccount": true,
"fsAlias": "string",
"hasBalance": true,
"title": "string",
"type": {
"id": "string",
"title": "string"
}
}
]
}
Answer the question
In order to leave comments, you need to log in
Something like this...
import json
myjson = """
{
"accounts": [
{
"alias": "string",
"balance": {
"amount": 0,
"currency": 0
},
"bankAlias": "string",
"currency": 0,
"defaultAccount": true,
"fsAlias": "string",
"hasBalance": true,
"title": "string",
"type": {
"id": "string",
"title": "string"
}
}
]
}
"""
data = json.loads(myjson)
print data["accounts"][0]["balance"]["amount"]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question