classafBedSheet::JsonResult
sys::Obj afBedSheet::JsonResult
Return from Handler methods to send a JSON response to the client.
This is purposely a concrete final class so there's no ambiguity as to what it is. For example, if a handler returned an Obj that was both a TextResult
and a "JsonResult' what is BedSheet supposed to do?
Best practice is to have your Entities have a toText()
or toJson()
method and return that.
Obj myHandler(MyEntity entity) { ... return entity.toJson }
- make
new make(Obj jsonObj)
The jsonObj should be serialisable into Json via JsonOutStream
- toJsonStr
Str toJsonStr()
Converts the wrapped Obj into JSON via JsonOutStream.writeJsonToStr