Not able to convert %Stream.TmpBinary; to JSON property
Hello,
I’m creating a REST API service but I need to convert my object in JSON.
Class message_B Extends Ens.Request
{
Property ClientId As %String(MAXLEN = "");
Property mesagge As %Stream.TmpBinary;
}
set pRequest = ##Class(message_B).%New()
do ##class(Ens.Util.JSON).ObjectToJSONStream(pRequest, .content)
it is ignoring message property in json dueto its data type %Stream.TmpBinary
Could you please help me to resolve it?
Product version: IRIS 2022.1
Discussion (2)0
Comments
I do not use Ensemble, but I would try using the JSON-Adaptor, something like this
Class MessageB Extends (Ens.Request, %JSON.Adaptor)
{
Property ClientId As%String(MAXLEN = "");Property message As%Stream.TmpBinary;
}
For example
sr=##class(MessageB).%New()
sr.ClientId=12345dr.message.Write("part1")
dr.message.Write("part2")
wr.%JSONExportToStream(.s)
ds.Rewind()
ws.Read(s.Size) --> {"ClientId":"12345","message":"cGFydDFwYXJ0Mg=="}Thanks a lot this works for me