Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有返回 json 的原子值(用户/hasPrivilege 等)有意义的操作,并且希望我的响应只包含“true”或“false”,我还希望能够发送原始数字和字符串. 我认为这些将被视为有效的 json,但得到错误:
Value out of sequence: expected mode to be OBJECT or ARRAY when writing 'false' but was INIT
当接受标头是 json 时,是否可以指示 Grails 序列化这些?
由于这些值是有效的 json,Groovy JsonOutput 似乎确实将它们转换为 Json 字符串:
import groovy.json.* JsonOutput.toJson(true) >>> true
</p>
那么难道不能用 JsonOutput 转换并用它而不是 Grails 来响应as JSON吗?
as JSON