- Log in to post comments
User bio
404 bio not found
Member since Jan 24, 2019
Posts:
Replies:
I don't know if i will prefer override the %JSONExportToString and %JSONExportToStream or wrapping but that dirty trick..
Class test.elementList Extends (%ListOfObjects, %JSON.Adaptor)
{
/// The type (class name) of the elements stored in the collection.
Parameter ELEMENTTYPE = "test.element";
/// Returns this object as a JSON Stream
Method %JSONExportToStream(ByRef objStream As %Stream.Object, %mappingName As %String = "") As %Status
{
#Dim objStream As %Stream.TmpCharacter = ##class(%Stream.TmpCharacter).%New()
Do objStream.Write("[")
For i=1:1:..Size
{
Do ..GetAt(i).%JSONExportToStream(.objStream, %mappingName)
If (i<..Size)
{
Do objStream.Write(",")
}
}
Do objStream.Write("]")
Return $$$OK
}
/// Returns this object as a JSON string
Method %JSONExportToString(ByRef jsn As %String, %mappingName As %String = "") As %Status
{
#Dim jsonElement As %String = ""
Set jsn = "["
For i=1:1:..Size
{
Set jsonElement = ""
Do ..GetAt(i).%JSONExportToString(.jsonElement, %mappingName)
Set jsn = jsn_jsonElement
If (i<..Size)
{
Set jsn = jsn_","
}
}
Set jsn = jsn_"]"
Return $$$OK
}
}- Log in to post comments
Yep, i will put this as a post from IRIS ;)
- Log in to post comments
Certifications & Credly badges:
Javier has no Certifications & Credly badges yet.
Followers:
Javier has no followers yet.
Following:
Javier has not followed anybody yet.
IF you are usng IRIS or CACHE you will need the corresponding jdbc driver from intersystems.
Then create a jdbc conection using the driver and the connection string.
IRIS doc: https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=AFL_JDBC
Cache doc : https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=BGJD_intro