Json 或原生 pojo

Json or native pojo

我和我的团队辩论, 我休息一下 return 一些 certian 格式的东西 格式看起来像这样

{  
    Name:{  
        Inner:[  
            {  
                inner:[  
                    {  
                        inner:"hdjdjd"
                    }
                ]
            }
        ]
    }
}

在ws中我return这种格式的数据只有一次。

我的团队认为我应该在响应方法中使用 jacksons 对象节点创建 json。 而且我认为我应该在 pojo class 中建模格式,然后 return class json 表示(使用杰克逊) 正确的选项是什么?

这是一个品味问题。

如果这个 JSON 格式没有使用一次,我建议你创建 DTO or POJO* 对象并 return 它。

否则,return一个jacksons对象节点,为什么不呢?

* All DTOs are POJOs, but not all POJOs are DTOs. An example of POJO that is not a DTO is a business class that contains state and behavior (business logic).