I'm consuming an API that returns a list a of objects in a JSON. But when I get its content with Requests lib, the content is a byte array of objects like this :
b'[{"id":44,"id_string":"a2BPQDsGLfLiwo4r5U4JCY","title":"ED_1803_ITAIPAVA_RJ","description":"ED_1803_ITAIPAVA_RJ","url":"https://kobocat.docker.kobo.techo.org/api/v1/data/44"},{"id":57,"id_string":"a3pb3ALiGuQAHD6XzdHAip","title":"ED_v2018_1801_Taba\xc3\xa7u-SP","description":"ED_v2018_1801_Taba\xc3\xa7u-SP","url":"https://kobocat.docker.kobo.techo.org/api/v1/data/57"},{"id":68,"id_string":"a4Gz2dSwRuyQCsjBwNhf3D","title":"ECS_1804_SONHO REAL-BA","description":"ECS_1804_SONHO REAL-BA","url":"https://kobocat.docker.kobo.techo.org/api/v1/data/68"},{"id":2,"id_string":"a4KjYoy8ieCRNykiYb7nGP","title":"ECS_1708_Vila Esperan\xc3\xa7a-SP","description":"ECS_1708_Vila Esperan\xc3\xa7a-SP","url":"https://kobocat.docker.kobo.techo.org/api/v1/data/2"},{"id":38,"id_string":"a7GQQ7xEu4K6HXWYu9SaSC","title":"ECo_1711_Terra Nossa-UF","description":"ECo_1711_Terra Nossa-UF","url":"https://kobocat.docker.kobo.techo.org/api/v1/data/38"},{"id":78,"id_string":"a7NnnbdhBUSsGoxVWBiGFb","title":"ECoSP_1805_Vila Nova Esperan\xc3\xa7a-SP","description":"ECoSP_1805_Vila Nova Esperan\xc3\xa7a-SP","url":"https://kobocat.docker.kobo.techo.org/api/v1/data/78"}]
How can I make it a normal list of dictionares? I tried iterating through the byte array with for in range() , but all I can return are numbers.
You can do this:
import json
dic = json.loads(Your_input)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With