Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonParseException: Unexpected character #54

Closed
zholmes1 opened this issue Oct 17, 2014 · 2 comments
Closed

JsonParseException: Unexpected character #54

zholmes1 opened this issue Oct 17, 2014 · 2 comments

Comments

@zholmes1
Copy link
Contributor

I am trying to implement Netagio's new API into XChange but I'm unable to parse their JSON response, due to an odd character in the response which seems to crash Jackson.

Here is the character: http://www.fileformat.info/info/unicode/char/feff/index.htm

The stack trace:

Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Unexpected character ('' (code 65279 / 0xfeff)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: java.io.StringReader@243c4f91; line: 1, column: 2]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1524)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:557)
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:475)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1415)
    at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:679)
    at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3031)

And the raw JSON: http://pastebin.com/raw.php?i=UBxKKSaF

Seems like the exchange is doing something weird when they generate their JSON. There are some other people who have had the same issue. See here: https://stackoverflow.com/questions/10188899/json-object-parsing-error

Any ideas?

@mmazi
Copy link
Owner

mmazi commented Oct 17, 2014

A couple of proposed soultions: one, two.

This could be solved in rescu in HttpTemplate prior to passing the stream to Jackson.

@zholmes1
Copy link
Contributor Author

See #55

jkieberk pushed a commit to jkieberk/yetibot that referenced this issue Mar 25, 2017
-Idea from: mmazi/rescu#54 (comment)

Not sure if this is something that clj-http should be stripping out
on their end? This might just be a hack, and there is a better way
to go about this?

Also, adding [cheshire] as a dependency might fix it as well, although when I
tried that, it still gave the same error (cheshire is a dependency
of clj-http when using the :as :json feature of clj-http/get
see [here](https://github.com/dakrone/clj-http#optional-dependencies) )
jkieberk pushed a commit to jkieberk/yetibot that referenced this issue Mar 25, 2017
-Idea from: mmazi/rescu#54

Not sure if this is something that clj-http should be stripping out
on their end? This might just be a hack, and there is a better way
to go about this?

Also, adding [cheshire] as a dependency might fix it as well, although when I
tried that, it still gave the same error (cheshire is a dependency
of clj-http when using the :as :json feature of clj-http/get
see [here](https://github.com/dakrone/clj-http#optional-dependencies) )
jkieberk pushed a commit to jkieberk/yetibot that referenced this issue Mar 25, 2017
-Idea from: mmazi/rescu#54

Not sure if this is something that clj-http should be stripping out
on their end? This might just be a hack, and there is a better way
to go about this?

Also, adding [cheshire] as a dependency might fix it as well, although when I
tried that, it still gave the same error (cheshire is a dependency
of clj-http when using the :as :json feature of clj-http/get
see [here](https://github.com/dakrone/clj-http#optional-dependencies) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants