1、错误描述


    com.alibaba.fastjson.JSONException: syntax error, pos 1  
        at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1083)  
        at com.alibaba.fastjson.parser.DefaultJSONParser.parse(DefaultJSONParser.java:1009)  
        at com.alibaba.fastjson.JSON.parse(JSON.java:89)  
        at com.alibaba.fastjson.JSON.parse(JSON.java:80)  
        at com.alibaba.fastjson.JSON.parseObject(JSON.java:151)  
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)  
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)  
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)  
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)  
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)  
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)  
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)  
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)  
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
        at java.lang.reflect.Method.invoke(Method.java:606)  
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)  
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)  
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)  
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)  
        at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)  
        at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)  
        at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)  
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233)  
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)  
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)  
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)  
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)  
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)  
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)  
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)  
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)  
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)  
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)  
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)  
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)  
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)  

2、错误原因

public Object getQueryStudent()throws Exception{  
     JSONObject json = this.getData(CDKM);  
     return queryStudent(json);  
}  
当this.getData(CDKM)没有返回值或者无值时,json就会报这个错误

3、解决办法

     给json对象赋值前先判断有无数据,如果有直接这样赋值;否则返回null


GitHub 加速计划 / fastj / fastjson
25.69 K
6.51 K
下载
FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
最近提交(Master分支:3 个月前 )
c942c834 - 1 年前
5bc4709b - 1 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐