Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71541
| From | Ben Finney <ben@benfinney.id.au> |
|---|---|
| Subject | Re: problems decoding json objects |
| Date | 2014-05-14 19:20 +1000 |
| References | <53732AFB.8080204@googlemail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9993.1400059238.18130.python-list@python.org> (permalink) |
Tamer Higazi <th982a@googlemail.com> writes:
> myjs =
> '{"AVName":"Tamer","ANName":"Higazi","AAnschrift":"Bauerngasse","AHausnr":"1","APLZ":"55116","AOrt":"Mainz"},{"KontaktTel":["01234","11223344"],{"ZahlungsArt":"0"},{"ZugangsDaten":["tamer.higazi@nomail.com","mypass"]}'
That's not a valid JSON document. See <URL:http://json.org/>.
You appear to have three documents in a row, separated by commas. Or one
malformed document, missing its enclosure.
Or something else; that's the trouble with a malformed document, we
don't know what it should be.
> I get this error message:
>
> >>> JSD.decode(myjs)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib64/python2.7/json/decoder.py", line 368, in decode
> raise ValueError(errmsg("Extra data", s, end, len(s)))
> ValueError: Extra data: line 1 column 108 - line 1 column 220 (char 107
> - 219)
Right. The document ends there, and the rest of the string is trailing
garbage, which is an error.
> How do I solve this problem ?!
Fix the document. Where did it come from?
Best, don't put it directly in the Python source code as a string.
Ideally, have it as a distinct file, which you can examine in a text
editor with JSON highlighting; and run separately through a JSON parser
for correctness.
--
\ “Isn't it enough to see that a garden is beautiful without |
`\ having to believe that there are fairies at the bottom of it |
_o__) too?” —Douglas Adams |
Ben Finney
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: problems decoding json objects Ben Finney <ben@benfinney.id.au> - 2014-05-14 19:20 +1000
csiph-web