Reputation: 13910
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?
EDIT: The output is from an Avro file, the Avro package uses jackson to emit records as JSON.
EDIT2: After poking about in the source files, it might be the case that the JSON is constructed manually (sorry jackson).
Upvotes: 4
Views: 1556
Reputation: 954
This is a known bug in Avro versions < 1.6.0. See AVRO-851 for more details.
Upvotes: 0
Reputation: 66973
Jackson does not currently have a configuration feature to allow accepting such input. (Was it generated with Jackson?)
You could modify the stream parser to handle it. Follow the stack trace to the method(s) that would need changing.
You could submit a change request at http://jira.codehaus.org/browse/JACKSON for Jackson to be enhanced to provide such a feature, though I'm not sure how popular the request would be, and whether it would ever be implemented.
Upvotes: 0
Reputation: 28069
Basically the input isn't valid json.
The spec on http://www.json.org/ defines how strings should be be encoded. You will have to fix the JSON output from the other application.
Upvotes: 1
Reputation: 12663
Try quoting the \u
like this:
{
"description": "... lives\\uMOVE™ OFFERS ",
}
Upvotes: 1
Reputation: 13289
What's the original string supposed to look like? \uXXXX
is a unicode escape sequence, so it's interpreting \uMOVE as a single character, but it's not a valid unicode value. JSON is always assumed to be unicode, so you'll likely need to fix the string in the originating app
Upvotes: 4