2
I am working with the Buscapé API in order to get information from some products on the site, the problem is that I cannot manipulate one of the values of the returned json. Below follows some results I managed to obtain:
resp = buscape.find_product_list(keyword='jogos', format='json') # Fazendo a consulta
resp.keys() # Retornou: 'dict_keys(['data', 'code'])'
type(resp['code']) # Retornou: '<\class 'int>'
type(resp['data']) # Retornou: '<\class 'bytes>'
As you can see, when I checked the type of Resp['data'] (field that holds the values I need) python returned me the value "class bytes", with this, I can even convert this value to string, the problem is that it would be laborious to seek out every piece of information I need in this way .
I’ve tried the dump like this:
import json
json.dumps(resp)
But the integer returns me the following error: is not JSON serializable.
Guys, I was able to solve the problem, I only had to do the Code('utf-8') of the field Resp['data'], so I was able to do json.loads and manipulate the information I needed.
– André Ramos
André, put your answer down here (answers section) in case someone wants to know also about this problem!
– Vinicius Mesel
Solved your doubt?
– durtto