Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy does json ObjectMapper throw java.io.EOFException: No content to map to Object due to end of input
    primarykey
    data
    text
    <p>I have a response from a REST web service that looks like this:-</p> <pre><code>{ "number":447919191231, "messages":"", "receipt":{ "uid":"5d1bddf5-1b98-4a32-8ebf-f71c3973e7a8", "messages":"", "status":"SUCCESS", "code":"09641", "ttl":120, "url":"http:\/\/server:8080\/x\/d6985" } } </code></pre> <p>and I am attempting to use the method outlined here in the full data binding example</p> <p><a href="http://wiki.fasterxml.com/JacksonInFiveMinutes#Full_Data_Binding_.28POJO.29_Example" rel="nofollow noreferrer">http://wiki.fasterxml.com/JacksonInFiveMinutes#Full_Data_Binding_.28POJO.29_Example</a></p> <p>I have created a class which looks like this:-</p> <pre><code>public class ReceiptResponse { private int _number; private String _messages; private Receipt _receipt; public int getNumber() { return _number; } public void setNumber(int number) { this._number = number; } public String getMessages() { return _messages; } public void setMessages(String messages) { this._messages = messages; } public Receipt getReceipt() { return _receipt; } public void setReceipt(Receipt receipt) { this._receipt = receipt; } public static class Receipt { private String _uid; private String _messages; private String _status; private int _code; private int _ttl; private String _url; public String getUid() { return _uid; } public void setUid(String uid) { this._uid = uid; } public String getMessages() { return _messages; } public void setMessages(String messages) { this._messages = messages; } public String getStatus() { return _status; } public void setStatus(String status) { this._status = status;} public int getCode() { return _code; } public void setCode(int code) { this._code = code; } public int getTtl() { return _ttl; } public void setTtl(int ttl) { this._ttl = ttl; } public String getUrl() { return _url; } public void setUrl(String url) { this._url = url; } } } </code></pre> <p>My code to parse this response looks like this:-</p> <pre><code>ObjectMapper mapper = new ObjectMapper(); ReceiptResponse response = mapper.readValue(method.getResponseBodyAsStream(), ReceiptResponse.class); </code></pre> <p>But it throws the following error:-</p> <pre><code>12:03:44,195 ERROR [STDERR] Fatal transport error: No content to map to Object due to end of input 12:03:44,195 ERROR [STDERR] java.io.EOFException: No content to map to Object due to end of input 12:03:44,196 ERROR [STDERR] at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:1630) 12:03:44,196 ERROR [STDERR] at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:1580) 12:03:44,196 ERROR [STDERR] at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1158) </code></pre> <p>Can anyone help me by explaining why this is happening? I thought perhaps it was because the messages are empty, but I tried putting dummy data in there and it still failed. I've looked for the ObjectMapper code and it seems to think it can't find the first token (am i correct?) but I can't see why it won't be able to find it? </p> <p>any help would be appreciated! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload