E
E
Elvis2017-05-02 18:59:24
Python
Elvis, 2017-05-02 18:59:24

How to get path to JSON value?

There is JSON, for example:

{
    "expand":"renderedFields,names,schema,transitions,operations,editmeta,changelog",
    "id":"650784",
    "self":"https://jira.ru/rest/api/2/issue/650784",
    "key":"HCS-57601",
    "fields":{
        "status":{
            "self":"https://jira.ru/rest/api/2/status/11055",
            "description":"",
            "iconUrl":"https://jira.ru/images/icons/statuses/generic.png",
            "name":"Валидация дефектов",
            "id":"11055"
        },
        "priority":{
            "self":"https://jira.lanit.ru/rest/api/2/priority/1",
            "iconUrl":"https://jira.ru/images/icons/priorities/blocker.png",
            "name":"Blocker",
            "id":"1"
        },
        "fixVersions":[
            {
                "self":"https://jira.ru/rest/api/2/version/26395",
                "id":"26395",
                "name":"11.1.1",
                "archived":false,
                "released":false,
                "releaseDate":"2017-04-28"
            }
        ]
    }
}

How can I pull out the path to the value, for example "Blocker"?
That is, to give me the output:
['fields']['status']['name']

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2017-05-02
@IonDen

First ask yourself the question, how do you get to "Blocker"?
1. You will convert json into an object
2. You will bypass this object with some algorithm to find the desired value.
3. You will find value.
Accordingly, in order to get the "path" to the value, you must store it yourself in a variable as you search for the desired value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question