Omar Jandali
Omar Jandali

Reputation: 824

Parsing and saving Json response values - Django

I have a django project that sent a json request and now I am getting json back. There are certain values from the json reponse that I want to save into a model that I created that will store the information gathered. I couldnt find a way to parse the data and save the data that was taken... Here is a sample response that I am using which has information that I want to extract...

{  
   '_id':'..e154e57',
   '_links':{  
      'self':{  
         'href':'https://uat-api.synapsefi.com/v3.1/users/..002e154e57'
      }
   },
   'client':{  
      'id':'..1026a34',
      'name':'Charlie Brown LLC'
   },
   'doc_status':{  
      'physical_doc':'MISSING|INVALID',
      'virtual_doc':'MISSING|INVALID'
   },
   'documents':[  

   ],
   'emails':[  

   ],
   'extra':{  
      'cip_tag':1,
      'date_joined':1504774195147,
      'extra_security':False,
      'is_business':True,
      'last_updated':1504774195147,
      'public_note':None,
      'supp_id':'123abc'
   },
   'is_hidden':False,
   'legal_names':[  
      'Hello McHello'
   ],
   'logins':[  
      {  
         'email':'[email protected]',
         'scope':'READ_AND_WRITE'
      }
   ],
   'permission':'UNVERIFIED',
   'phone_numbers':[  
      '555-555-5555'
   ],
   'photos':[  

   ],
   'refresh_token':'..C1tdG8LPqF6'
}

sample peices of information I want are id, sip, supp, joined, refresh tocken

Upvotes: 0

Views: 342

Answers (1)

Alex
Alex

Reputation: 1262

Have you tried:

import json

my_dict = json.loads(my_json_response)

You should get a dictionary to work with.

Upvotes: 1

Related Questions