Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么域类中的非类型化属性不能呈现为JSON_Json_Grails - Fatal编程技术网

为什么域类中的非类型化属性不能呈现为JSON

为什么域类中的非类型化属性不能呈现为JSON,json,grails,Json,Grails,为什么在呈现以下域类时会有差异 class Foo { String code } 还有这个 class Foo { def code } 如果我在restful控制器中呈现这个实例 def show() { respond new Foo(code: "some_value") } 第一个示例将呈现为 {"class":"Foo","id":null,"code":"some_value"} 其中,作为第二个示例,将仅渲染为 {"class":"Foo","

为什么在呈现以下域类时会有差异

class Foo {
    String code
}
还有这个

class Foo {
    def code
}
如果我在restful控制器中呈现这个实例

def show() {
    respond new Foo(code: "some_value")
}
第一个示例将呈现为

 {"class":"Foo","id":null,"code":"some_value"}
其中,作为第二个示例,将仅渲染为

 {"class":"Foo","id":null}

我怀疑是因为封送员不知道要使用什么数据类型,所以会忽略它。