I have a packages encoded by URL-encoded unpadded base64. It's looks like this:
b'DbMG_38MBgb8ru_RlDE1'
So I have a simple code which must turn this JSON bytes to Python object
import base64, json
b = b'DbMG_38BBgaI0Kv6kzGK'
a = base64.urlsafe_b64decode(b)
c = json.loads(a)
From b'DbMG_38BBgaI0Kv6kzGK' it should turn out this:
[
{
"length": 13,
"payload": {
"src": 819,
"dst": 16383,
"serial": 1,
"dev_type": 6,
"cmd": 6,
"cmd_body": {
"timestamp": 1688984021000
}
},
"crc8": 138
}
]
But I have an error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 1: invalid start byte
Also I have tried:
c = a.decode('utf-8') # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 1: invalid start byte
c = a.decode('utf-16') # UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x8a in position 14: truncated data
c = a.decode('ascii') # UnicodeDecodeError: 'ascii' codec can't decode byte 0xb3 in position 1: ordinal not in range(128)
But this is not working
The variable a contains:
b'\r\xb3\x06\xff\x7f\x01\x06\x06\x88\xd0\xab\xfa\x931\x8a'
Please help me decode this bytes I'm at a dead end