nutzam/nutz — Issue #103: JsonAdaptor转换问题
Author: enzozhong
Created: 2011-11-06 21:08:21+00:00
State: open

public class Catalogo {
@Id
private Long id;
@Column
private String name;
}

@At("create")
@Ok("json")
@AdaptBy(type = JsonAdaptor.class)
public void create(@Param("cs")Catalogo[] cs) {
for (Catalogo c : cs) {
System.out.println(c);
}
}

前台
var catalogo = [{id : 1,name : a},{id : 2,name : b}]
$.ajax({
url : "/catalogo/create",
data : {
cs : catalogo
},
type : "post",
dataType : "json",
success : function(res) {

}
});

错误
org.nutz.json.JsonException: !Json syntax error nearby [row:0,col:0 char 'c'], reason: 'Unexpected char'
at org.nutz.json.JsonCompile.unexpectedChar(JsonCompile.java:414)
at org.nutz.json.JsonCompile.parseSimpleType(JsonCompile.java:250)
at org.nutz.json.JsonCompile.parseFromHere(JsonCompile.java:73)
at org.nutz.json.JsonCompile.parse(JsonCompile.java:52)
at org.nutz.json.Json.fromJson(Json.java:59)
at org.nutz.json.Json.fromJson(Json.java:118)
at org.nutz.mvc.adaptor.JsonAdaptor.getReferObject(JsonAdaptor.java:36)
at org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:171)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:28)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:42)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:82)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:36)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:60)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)