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


Groups > comp.lang.python > #53389

Re: How do I process this using Python?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <papillion@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string.': 0.05; 'subject:Python': 0.06; 'json': 0.07; 'string': 0.09; 'indicates': 0.09; 'prefix': 0.09; 'prefixes': 0.09; 'subject:process': 0.09; 'subject:using': 0.09; 'wrapped': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'json,': 0.16; 'parser.': 0.16; 'remembered': 0.16; 'simpson': 0.16; 'string:': 0.16; 'unicode?': 0.16; 'wrote:': 0.18; 'example': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'processor': 0.24; 'unicode': 0.24; 'cheers,': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'returned': 0.30; "i'm": 0.30; 'sep': 0.31; 'guess': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'subject:?': 0.36; 'message-id:@gmail.com': 0.38; 'pm,': 0.38; 'does': 0.39; 'sure': 0.39; 'how': 0.40; 'is.': 0.60; 'you.': 0.62; 'needing': 0.65; 'subject:this': 0.83; 'right!': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=M3P8ikGl/4C+e0wZolmcHKBPyr7ZDtPFwGEgPxvwp+Q=; b=Ycyjz3/t4ntSYV76LM6lDiEY0eUMcsqvH0YUbxurmaBNNajAhQuztcTQEyWZZrjp/E 4GpewCS+5Q0noxrgAYP88C2gm1XoKZcVGV8dA7dhyvP2KjnjZnTCQaZd6nFcbZu0CBqB Thr36aY4KrtzIdsp1FEIFAa35cKoeXg7EB/UtfcMWQc8FYj23kqn0d5AVRCzcg2iPyPs 8AWYaNOYzz07Fn7BWoR0/D7/VAC6jCbq5Au0t6o6cXdrVX558SDtgZMST7nhigfFKPHr XJ96J/V61Eg4DNoqjIDJXd9DDi+pr2ZbtuWTi4zZ1FJGesqE4asBhJbqdo67lAINj25W 6qiw==
X-Received by 10.60.51.196 with SMTP id m4mr12055367oeo.1.1377996345290; Sat, 31 Aug 2013 17:45:45 -0700 (PDT)
Date Sat, 31 Aug 2013 19:45:44 -0500
From Anthony Papillion <papillion@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8
MIME-Version 1.0
To Cameron Simpson <cs@zip.com.au>
Subject Re: How do I process this using Python?
References <5222881C.8060205@gmail.com> <20130901003224.GA32086@cskk.homeip.net>
In-Reply-To <20130901003224.GA32086@cskk.homeip.net>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.434.1377996347.19984.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377996347 news.xs4all.nl 15999 [2001:888:2000:d::a6]:45611
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53389

Show key headers only | View raw


On 08/31/2013 07:32 PM, Cameron Simpson wrote:
> On 31Aug2013 19:19, 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?
> | 
> | 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?
> 
> How sure are you that it is JSON? It looks to me like a message
> that might once have been JSON, but has already been passed through
> json.loads() for you.
> 
> What does type(the_json) say? What does repr(the_json) say?
> Print both.
> 
> I would guess it has already been parsed.
> 
> Cheers,

And you would be right! It's actually a dictionary!

Anthony

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How do I process this using Python? Anthony Papillion <papillion@gmail.com> - 2013-08-31 19:45 -0500

csiph-web