Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53388 > unrolled thread

Re: How do I process this using Python?

Started byChris Angelico <rosuav@gmail.com>
First post2013-09-01 10:32 +1000
Last post2013-09-01 10:32 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How do I process this using Python? Chris Angelico <rosuav@gmail.com> - 2013-09-01 10:32 +1000

#53388 — Re: How do I process this using Python?

FromChris Angelico <rosuav@gmail.com>
Date2013-09-01 10:32 +1000
SubjectRe: How do I process this using Python?
Message-ID<mailman.432.1377995530.19984.python-list@python.org>
On Sun, Sep 1, 2013 at 10:19 AM, Anthony Papillion <papillion@gmail.com> wrote:
> On 08/31/2013 06:48 PM, Chris Angelico wrote:
>> On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion <papillion@gmail.com> wrote:
>>> I'm writing a processor for Bitmessage messages and I am needing to
>>> parse the following returned JSON string:
>>>
>>> {u'inboxMessages':
>>
>> Does the JSON string really have those u prefixes and apostrophes?
>> That's not valid JSON. You may be able to use ast.literal_eval() on it
>> - I was able to with the example data - but not a JSON parser. Can you
>> sort out your transmission end?
>>
>> ChrisA
>
> I think I remembered what the 'u' prefix is. It indicates that the data
> following is a unicode string. So could that be valid JSON data wrapped
> up in unicode?

No; JSON already supports Unicode. What you may have is an incorrect
JSON encoder that uses Python's repr() to shortcut its work - but it's
wrong JSON.

But bitmessage seems to be written in Python. Can you simply access
the objects it's giving you, rather than going via text strings?

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web