Converting JSON objects in to dictionary in python

前端 未结 3 993
余生分开走
余生分开走 2020-12-17 17:30

I have string of data basically which has a objects with in the objects..

{\"id\":\"XXXX\", \"name\": \"xyz\", \"user\" : { \"id\": \"XXXX\", \"username\":\"         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 18:30

    I have figured out how to generate the_dict['user']['group']['id'] dynamically through Python's eval expression.

    Keys is the input from the user, separated by :. Example: user:group:id.

    CODE:

    RefCount = 0
    RespDict = json.loads(JSON_Datalist.content) #convert strings to Java object using JSON
    SplitKeys = Keys.split(":") 
    KeyCount = len(SplitKeys)
    CommandText = "RespDict" #To setup command line based on keys information
    while (RefCount 

提交回复
热议问题