[英]JsonSlurper generating different result between single-quoted and double-quoted input
I want to convert a String to json and using 我想将String转换为json并使用
JsonSlurper.parseText("{'name' : 'robel'}")
is Throwing Exception. JsonSlurper.parseText("{'name' : 'robel'}")
正在抛出异常。
I tried changing it to 我尝试将其更改为
JsonSlurper.parseText('{"name" : "robel"}')
and it works fine. 而且效果很好。 All i did to the first code is substitute the the single cote with double cote and vice versa .can some one tell me why this is happening and how to solve it?
我对第一个代码所做的全部工作是将单个棚替换为双棚,反之亦然。有人可以告诉我为什么会这样以及如何解决吗?
Both things in your question are the same? 您的问题中的两件事都一样吗?
Json requires double quotes Json需要双引号
You need an instance of JsonSlurper, and double quotes in your json: 您需要一个JsonSlurper实例,并在json中使用双引号:
new JsonSlurper().parseText('{"name" : "robel"}')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.