NutzCN Logo
问答 nutzJson问题
发布于 2746天前 作者 蛋蛋的忧伤 1658 次浏览 复制 上一个帖子 下一个帖子
标签:
           String con = response.getContent();         //从微信那获取了所有用户
            NutMap nm = Json.fromJson(NutMap.class, con);
            String opens = nm.get("data").toString();
            System.out.println(opens);  //此处是{openid=[o40mIwtadDsmVvgsdgwerijHU, o40gsdghhRMV08AGb4a5uQ, o40mIfsdfgsdg7HLfaXH0lsuug]}
            NutMap openid = Json.fromJson(NutMap.class,opens);  //报错了...
            System.out.println(openid);

报错信息:

org.nutz.json.JsonException: !Json syntax error nearby [row:1,col:9 char '['], reason: 'Unexpect Char'

	at org.nutz.json.impl.JsonTokenScan.unexpectChar(JsonCompileImplV2.java:433)
	at org.nutz.json.impl.JsonTokenScan.readMap(JsonCompileImplV2.java:186)
	at org.nutz.json.impl.JsonTokenScan.read(JsonCompileImplV2.java:340)
	at org.nutz.json.impl.JsonCompileImplV2.parse(JsonCompileImplV2.java:26)
	at org.nutz.json.Json.fromJson(Json.java:42)
	at org.nutz.json.Json.parse(Json.java:77)
	at org.nutz.json.Json.fromJson(Json.java:58)
	at org.nutz.json.Json.fromJson(Json.java:163)
	at com.hauge.weixinTest.WxTest.getMembersList(WxTest.java:36)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

改咋转啊.....

3 回复
            NutMap data = nm.getAs("data", NutMap.class);
            List<String> openids = data.getList("openids", String.class);

openids 应该是openid的样子, key改一下

添加回复
请先登陆
回到顶部