Json   发布时间:2022-04-22  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了com.alibaba.fastjson.JSONException: syntax error, pos 1大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

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$@L_861_3@methodInvocation.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、错误原因

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

3、解决办法

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

大佬总结

以上是大佬教程为你收集整理的com.alibaba.fastjson.JSONException: syntax error, pos 1全部内容,希望文章能够帮你解决com.alibaba.fastjson.JSONException: syntax error, pos 1所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。