JSON error - Raspberry Pi Forums
i visitting api of oldschool runescape returns strings in json, won't work me.
current code:
if try example name itz_craft, error.
hope can me out problem can avoid problems later json, because going use much.
anyway!
edit:
see it's csv now, still stuck :/
current code:
code: select all
import json import urllib.request name = input('osrs name? ') url = 'http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player={0}'.format(name) open_url = urllib.request.urlopen(url) read_url = open_url.read().decode() format_to_string = str(read_url) j = json.loads(format_to_string) print(j)
if try example name itz_craft, error.
code: select all
osrs name? itz_craft traceback (most recent call last): file "/home/pi/programming/python3/runescape/json_test.py", line 11, in <module> j = json.loads(format_to_string) file "/usr/lib/python3.4/json/__init__.py", line 318, in loads return _default_decoder.decode(s) file "/usr/lib/python3.4/json/decoder.py", line 346, in decode raise valueerror(errmsg("extra data", s, end, len(s))) valueerror: data: line 1 column 7 - line 28 column 1 (char 6 - 315)
hope can me out problem can avoid problems later json, because going use much.
anyway!
edit:
see it's csv now, still stuck :/
can print "format_to_string" before run json.loads command.
have multiple json strings in 1 can't tell until see format of data returned.
have multiple json strings in 1 can't tell until see format of data returned.
raspberrypi
Comments
Post a Comment