Hi devs!
What is the best way to return JSON in IRIS for a GET request in a REST app?
This is how I do it now:
ClassMethod GetAllPersons() As%Stream.Object
{
d ..%SetContentType("application/json")
Set rset = ##class(dc.Sample.Person).ExtentFunc()
set stream=##class(%Stream.TmpCharacter).%New()
d stream.Write("[")
if rset.%Next() {
Set person = ##class(dc.Sample.Person).%OpenId(rset.ID)
Do person.%JSONExportToStream(.stream)
}
While rset.%Next() {
d stream.Write(",")
Set person = ##class(dc.Sample.Person).%OpenId(rse


.png)

.png)
.png)




