Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jussi Piitulainen Newsgroups: comp.lang.python Subject: Re: Joining Strings Date: Fri, 08 Apr 2016 08:02:36 +0300 Organization: A noiseless patient Spider Lines: 16 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="8436"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192IhlpSb2Ig/638cVDmSuDse9ja1YSFCg=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:QrYlxqqEdwOTypllSlg3tbbC14U= sha1:F3fkdH3ib3YJPj43wQeKNq/+Djg= Xref: csiph.com comp.lang.python:106645 Emeka writes: > Thanks it worked when parsed with json.load. However, it needed this > decode('utf'): > > data = json.loads(respData.decode('utf-8')) So it does. The response data is bytes. There's also a way to wrap a decoding reader between the response object and the JSON parser (json.load instead of json.loads): response = urllib.request.urlopen(command) # a stream of bytes ... please = codecs.getreader('UTF-8') # ... to characters result = json.load(please(response))