java json not marked as ignorable_java - Could not read JSON: Unexpected end-of-input in field name
I am developing a Spring MVC web application. I am not still develop the UI. So I am testing my services using Advance Rest Client tool.My Controller@Controller@RequestMapping("/testController")public
I am developing a Spring MVC web application. I am not still develop the UI. So I am testing my services using Advance Rest Client tool.
My Controller
@Controller
@RequestMapping("/testController")
public class TestController {
@Autowired
private TestService testService;
@RequestMapping(value = "/test", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE })
public
@ResponseBody void testMethod(@RequestBody TestParam testParam) {
String tenant = testParam.getTenantCode();
String testString = tenant + " is the tenant";
}
}
TestParam.java class
public class TestParam {
private String testVar;
private String tenantCode;
public String getTenantCode() {
return tenantCode;
}
public void setTenantCode(String tenantCode) {
this.tenantCode = tenantCode;
}
public String getTestVar() {
return testVar;
}
public void setTestVar(String testVar) {
this.testVar = testVar;
}
}
I send the request using Advance Rest Client and headers and request link has set correctly.
{"testVar":"Test","tenantCode":"DEMO"}
Request link
http://localhost:8080/myApp/controller/testController/test
It works correctly when TestParam has one veriable. When it becomes two or more it gives an Error and it not hit the testMethod.
exception is com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in field name at [Source:org.apache.catalina.connector.CoyoteInputStream@7b24d498; line: 1, column: 43]
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:181)
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.read(MappingJackson2HttpMessageConverter.java:173)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:135)
I went throw more articles and I still couldn't find the answer.ame":"pluto","password":"bla"},{"username":"topolino","password":"bla"}] But i receive this error: Resolving exception from handler [public void sequenziatore.server.presenter.LoginController.CheckLogin(java.util.Vector
java
json
spring
jackson
advanced-rest-client
|
this question
edited Apr 19 '16 at 13:52 asked Apr 19 '16 at 13:38
Kasun Kariyawasam 774 1 8 22 Your code looks ok. Can you try some other client like 'POSTman' and see if ARC is the one screwing up things. –
yogidilip Apr 19 '16 at 14:22
|
3 Answers
3
Increasing Content-Length: in header works
|
this answer answered Apr 19 '16 at 14:50
Kasun Kariyawasam 774 1 8 22 I don't think that it is a good practice though –
Paweł Psztyć Apr 24 '16 at 22:42
|
Whats your json format ? I think json format uses literal \n's as delimiters, please be sure that the JSON actions and sources are not pretty printed.
|
this answer answered Apr 19 '16 at 13:50
EL missaoui habib 394 3 10
|
There is an issue in ARC where there is no payload and the response is of a type of json. Parser is throwing error because the string is empty and the response report is crashing.
|
this answer answered Apr 20 '16 at 9:13
Paweł Psztyć 2,005 1 8 14
|
@Id String id; List skills; //getter/setters public static class Skill{ String name; Integer level; }} My JSON is {"id":"XXX","name":"john","skills":[{"name":"football","level":0}]} Whe
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)