2626 SEARCH_INDEX_ARGS ,
2727 SPECIAL_INDEX_TYPE ,
2828 TEXT_INDEX_TYPE ,
29- get_docs )
29+ get_docs ,
30+ response_to_json_dict ,
31+ )
3032from .document import Document
3133from .design_document import DesignDocument
3234from .security_document import SecurityDocument
@@ -123,7 +125,7 @@ def metadata(self):
123125 """
124126 resp = self .r_session .get (self .database_url )
125127 resp .raise_for_status ()
126- return resp . json ( )
128+ return response_to_json_dict ( resp )
127129
128130 def doc_count (self ):
129131 """
@@ -192,7 +194,7 @@ def design_documents(self):
192194 query = "startkey=\" _design\" &endkey=\" _design0\" &include_docs=true"
193195 resp = self .r_session .get (url , params = query )
194196 resp .raise_for_status ()
195- data = resp . json ( )
197+ data = response_to_json_dict ( resp )
196198 return data ['rows' ]
197199
198200 def list_design_documents (self ):
@@ -206,7 +208,7 @@ def list_design_documents(self):
206208 query = "startkey=\" _design\" &endkey=\" _design0\" "
207209 resp = self .r_session .get (url , params = query )
208210 resp .raise_for_status ()
209- data = resp . json ( )
211+ data = response_to_json_dict ( resp )
210212 return [x .get ('key' ) for x in data .get ('rows' , [])]
211213
212214 def get_design_document (self , ddoc_id ):
@@ -403,7 +405,7 @@ def all_docs(self, **kwargs):
403405 '/' .join ([self .database_url , '_all_docs' ]),
404406 self .client .encoder ,
405407 ** kwargs )
406- return resp . json ( )
408+ return response_to_json_dict ( resp )
407409
408410 @contextlib .contextmanager
409411 def custom_result (self , ** options ):
@@ -718,7 +720,7 @@ def bulk_docs(self, docs):
718720 headers = headers
719721 )
720722 resp .raise_for_status ()
721- return resp . json ( )
723+ return response_to_json_dict ( resp )
722724
723725 def missing_revisions (self , doc_id , * revisions ):
724726 """
@@ -742,7 +744,7 @@ def missing_revisions(self, doc_id, *revisions):
742744 )
743745 resp .raise_for_status ()
744746
745- resp_json = resp . json ( )
747+ resp_json = response_to_json_dict ( resp )
746748 missing_revs = resp_json ['missing_revs' ].get (doc_id )
747749 if missing_revs is None :
748750 missing_revs = []
@@ -771,7 +773,7 @@ def revisions_diff(self, doc_id, *revisions):
771773 )
772774 resp .raise_for_status ()
773775
774- return resp . json ( )
776+ return response_to_json_dict ( resp )
775777
776778 def get_revision_limit (self ):
777779 """
@@ -787,7 +789,7 @@ def get_revision_limit(self):
787789 try :
788790 ret = int (resp .text )
789791 except ValueError :
790- raise CloudantDatabaseException (400 , resp . json ( ))
792+ raise CloudantDatabaseException (400 , response_to_json_dict ( resp ))
791793
792794 return ret
793795
@@ -806,7 +808,7 @@ def set_revision_limit(self, limit):
806808 resp = self .r_session .put (url , data = json .dumps (limit , cls = self .client .encoder ))
807809 resp .raise_for_status ()
808810
809- return resp . json ( )
811+ return response_to_json_dict ( resp )
810812
811813 def view_cleanup (self ):
812814 """
@@ -822,7 +824,7 @@ def view_cleanup(self):
822824 )
823825 resp .raise_for_status ()
824826
825- return resp . json ( )
827+ return response_to_json_dict ( resp )
826828
827829 def get_list_function_result (self , ddoc_id , list_name , view_name , ** kwargs ):
828830 """
@@ -974,10 +976,10 @@ def get_query_indexes(self, raw_result=False):
974976 resp .raise_for_status ()
975977
976978 if raw_result :
977- return resp . json ( )
979+ return response_to_json_dict ( resp )
978980
979981 indexes = []
980- for data in resp . json ( ).get ('indexes' , []):
982+ for data in response_to_json_dict ( resp ).get ('indexes' , []):
981983 if data .get ('type' ) == JSON_INDEX_TYPE :
982984 indexes .append (Index (
983985 self ,
@@ -1239,7 +1241,7 @@ def share_database(self, username, roles=None):
12391241 headers = {'Content-Type' : 'application/json' }
12401242 )
12411243 resp .raise_for_status ()
1242- return resp . json ( )
1244+ return response_to_json_dict ( resp )
12431245
12441246 def unshare_database (self , username ):
12451247 """
@@ -1264,7 +1266,7 @@ def unshare_database(self, username):
12641266 headers = {'Content-Type' : 'application/json' }
12651267 )
12661268 resp .raise_for_status ()
1267- return resp . json ( )
1269+ return response_to_json_dict ( resp )
12681270
12691271 def shards (self ):
12701272 """
@@ -1276,7 +1278,7 @@ def shards(self):
12761278 resp = self .r_session .get (url )
12771279 resp .raise_for_status ()
12781280
1279- return resp . json ( )
1281+ return response_to_json_dict ( resp )
12801282
12811283 def get_search_result (self , ddoc_id , index_name , ** query_params ):
12821284 """
@@ -1399,4 +1401,4 @@ def get_search_result(self, ddoc_id, index_name, **query_params):
13991401 data = json .dumps (query_params , cls = self .client .encoder )
14001402 )
14011403 resp .raise_for_status ()
1402- return resp . json ( )
1404+ return response_to_json_dict ( resp )
0 commit comments