json decode issue

Discussion in 'Python' started by Miki Tebeka, Jul 14, 2011.

  1. Miki Tebeka

    Miki Tebeka Guest

    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
     
    Miki Tebeka, Jul 14, 2011
    #1
    1. Advertising

  2. Miki Tebeka

    MRAB Guest

    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.
     
    MRAB, Jul 14, 2011
    #2
    1. Advertising

  3. Miki Tebeka

    Terry Reedy Guest

    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
     
    Terry Reedy, Jul 14, 2011
    #3
  4. Miki Tebeka

    Nobody Guest

    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.
     
    Nobody, Jul 15, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Florian Frank
    Replies:
    0
    Views:
    266
    Florian Frank
    Jun 30, 2009
  2. sajuptpm
    Replies:
    2
    Views:
    407
    sajuptpm
    Dec 28, 2012
  3. Acácio Centeno
    Replies:
    1
    Views:
    313
    dieter
    Feb 15, 2013
  4. Bryan Britten
    Replies:
    9
    Views:
    298
    Bryan Britten
    May 28, 2013
  5. David Karr
    Replies:
    1
    Views:
    197
    David Karr
    Jun 17, 2013
Loading...

Share This Page