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


Groups > comp.lang.python > #91346

Re: Decoding JSON file using python

From random832@fastmail.us
References <11dbf982-efc1-4ef0-b286-e3d08ba5030e@googlegroups.com> <mailman.108.1432768474.5151.python-list@python.org> <75320b35-72b6-4aae-a47f-630bd7bef812@googlegroups.com>
Subject Re: Decoding JSON file using python
Date 2015-05-27 23:48 -0400
Newsgroups comp.lang.python
Message-ID <mailman.115.1432784915.5151.python-list@python.org> (permalink)

Show all headers | View raw



On Wed, May 27, 2015, at 19:51, Karthik Sharma wrote:
> I get the following error.
> 
> Traceback (most recent call last):
>   File "test_json.py", line 23, in <module>
>     print('message {} \n\n'.format(message['Message']))
> TypeError: list indices must be integers, not str
> karthik.sharma@aukksharma2:~$ vim test_json.py 

The string in data appears to be a json _list_ (note the first character
is a square bracket) - try message[0]['Message'].

You should really be able to figure this out yourself.

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


Thread

Decoding JSON file using python Karthik Sharma <karthik.sharma@gmail.com> - 2015-05-27 15:23 -0700
  Re: Decoding JSON file using python random832@fastmail.us - 2015-05-27 19:06 -0400
  Re: Decoding JSON file using python MRAB <python@mrabarnett.plus.com> - 2015-05-28 00:08 +0100
  Re: Decoding JSON file using python Cameron Simpson <cs@zip.com.au> - 2015-05-28 08:52 +1000
    Re: Decoding JSON file using python Karthik Sharma <karthik.sharma@gmail.com> - 2015-05-27 16:51 -0700
      Re: Decoding JSON file using python Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-05-28 01:38 +0000
        Re: Decoding JSON file using python Cameron Simpson <cs@zip.com.au> - 2015-05-28 13:32 +1000
          Re: Decoding JSON file using python Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-28 18:49 +0000
      Re: Decoding JSON file using python random832@fastmail.us - 2015-05-27 23:48 -0400
      Re: Decoding JSON file using python MRAB <python@mrabarnett.plus.com> - 2015-05-28 04:54 +0100
  Re: Decoding JSON file using python Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-28 18:48 +0000

csiph-web