Rendering 'as JSON' in Grails with conditional operator doesn't render correctly

前端 未结 4 725
不知归路
不知归路 2020-12-11 06:27

Came across this strange result today trying to render a list of objects as JSON in Grails 2.0.4...(i know i\'m gonna regret asking this on account of something right under

4条回答
  •  暖寄归人
    2020-12-11 06:58

    Don't know the reason. Try to use like this:

    render(contentType: 'text/json') {[
        'products': products ? : "No products found"
    ]}
    

提交回复
热议问题