how to get a real null value instead of a JSONObject.NULL value when parsing JSON in grails

后端 未结 3 565
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-19 08:17

I\'m trying to parse some JSON in Grails using the grails.converters.JSON library. I have a field which will contain either a string, or a null value. When I parse the JSON an

3条回答
  •  猫巷女王i
    2021-02-19 09:05

    Have a look at: http://grails.1312388.n4.nabble.com/The-groovy-truth-of-JSONObject-Null-td3661040.html

    Ian Roberts mentions a nice trick to make a null check possible:

    JSONObject.NULL.metaClass.asBoolean = {-> false} 
    

提交回复
热议问题