I have a socket in C sending this char[] (String) through a TCP socket:
{"time":0, "latitude":0.0000000, "longitude":0.0000000, "heading":0.000000, "roll":0.000, "pitch":0.000, "yaw":0.000}
It seems like it should be recognized as valid JSON in my Python client, but running:
parsed = json.loads(sock.recv(1024).decode('utf-8'))
Generates the following error:
ValueError: Extra data: line 1 column 117 - line 1 column 1024 (char 117 - 1024
Maybe C is throwing in some extra bits that Python doesn't like.
Figuring this was the case, I trying calling decode('ascii', 'ignore') on the input String hoping this would strip these characters out, but nothing has worked so far.
Any help would be greatly appreciated!
sock.recv(1024).decode('utf-8')I get{"time":0, "latitude":0.0000000, "longitude":0.0000000, "heading":0.000000, "roll":0.000, "pitch":0.000, "yaw":0.000}, as I would expect.print repr(sock.recv(1024).decode('utf-8'))?\x00\x00\x00characters. These are probably the problem. Can I get rid of them?repr()function existed!