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


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

json decode issue

Started byMiki Tebeka <miki.tebeka@gmail.com>
First post2011-07-14 10:22 -0700
Last post2011-07-15 06:10 +0100
Articles 4 — 4 participants

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


Contents

  json decode issue Miki Tebeka <miki.tebeka@gmail.com> - 2011-07-14 10:22 -0700
    Re: json decode issue MRAB <python@mrabarnett.plus.com> - 2011-07-14 20:20 +0100
    Re: json decode issue Terry Reedy <tjreedy@udel.edu> - 2011-07-14 16:03 -0400
    Re: json decode issue Nobody <nobody@nowhere.com> - 2011-07-15 06:10 +0100

#9479 — json decode issue

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2011-07-14 10:22 -0700
Subjectjson decode issue
Message-ID<87ac9918-c05c-482e-9789-ee90b1e9eb80@glegroupsg2000goo.googlegroups.com>
Greetings,

I'm trying to decode JSON output of a Java program (jackson) and having some issues.
The cause of the problem is the following snippet:
    {
        "description": "... lives\uMOVE™ OFFERS ",
    }
Which causes ValueError: Invalid \uXXXX escape.

Any ideas on how to fix this?

Thanks,
--
Miki

[toc] | [next] | [standalone]


#9483

FromMRAB <python@mrabarnett.plus.com>
Date2011-07-14 20:20 +0100
Message-ID<mailman.1034.1310671218.1164.python-list@python.org>
In reply to#9479
On 14/07/2011 18:22, Miki Tebeka wrote:
> Greetings,
>
> I'm trying to decode JSON output of a Java program (jackson) and having some issues.
> The cause of the problem is the following snippet:
>      {
>          "description": "... lives\uMOVE™ OFFERS ",
>      }
> Which causes ValueError: Invalid \uXXXX escape.
>
> Any ideas on how to fix this?
>
Is that valid JSON? If not, you'll either need to fix the program which
generated it (or report it as a bug), or pre-process the JSON to
correct the error, if you know what it should be.

[toc] | [prev] | [next] | [standalone]


#9486

FromTerry Reedy <tjreedy@udel.edu>
Date2011-07-14 16:03 -0400
Message-ID<mailman.1036.1310673800.1164.python-list@python.org>
In reply to#9479
On 7/14/2011 3:20 PM, MRAB wrote:
> On 14/07/2011 18:22, Miki Tebeka wrote:
>> Greetings,
>>
>> I'm trying to decode JSON output of a Java program (jackson) and
>> having some issues.
>> The cause of the problem is the following snippet:
>> {
>> "description": "... lives\uMOVE™ OFFERS ",
>> }
>> Which causes ValueError: Invalid \uXXXX escape.
>>
>> Any ideas on how to fix this?
>>
> Is that valid JSON? If not, you'll either need to fix the program which
> generated it (or report it as a bug), or pre-process the JSON to
> correct the error, if you know what it should be.

If you delete or double the backslash in that one particular spot, the 
string will parse, even if it is not correct.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#9504

FromNobody <nobody@nowhere.com>
Date2011-07-15 06:10 +0100
Message-ID<pan.2011.07.15.05.10.03.505000@nowhere.com>
In reply to#9479
On Thu, 14 Jul 2011 10:22:44 -0700, Miki Tebeka wrote:

> I'm trying to decode JSON output of a Java program (jackson) and having
> some issues. The cause of the problem is the following snippet:
>     {
>         "description": "... lives\uMOVE™ OFFERS ",
>     }
> Which causes ValueError: Invalid \uXXXX escape.
> 
> Any ideas on how to fix this?

It's the input data which is broken. The parser is behaving correctly by
raising an exception.

[toc] | [prev] | [standalone]


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


csiph-web