I think fairly straightforward approach works best
set l = ##class(%ListOfDataTypes).%New()
do l.Insert(1)
do l.Insert(2)
do l.Insert(4)
set lb = ""fori=1:1:l.Count() { set lb = lb _ $lb(l.GetAt(i)) }
zw lb
>lb=$lb(1,2,4)
%Collection.ListOfDT Serialize and deserialize methods seem like doing the trick.
But I found the documentation is a little bit ambiguous as the sample in the header refers itself to %ListOfDataTypes.
You're sure about that?
I understand these methods should only be used when the list property comes from a %Persistent object, but new instance with %New method is not allowed.
I think fairly straightforward approach works best
set l = ##class(%ListOfDataTypes).%New() do l.Insert(1) do l.Insert(2) do l.Insert(4) set lb = "" for i=1:1:l.Count() { set lb = lb _ $lb(l.GetAt(i)) } zw lb >lb=$lb(1,2,4)
thanks @Eduard Lebedyuk
Yes it works great. that's the way we did it. So no direct straight serialization system function. ;-)
There is actually. %GetSerial method builds a $lb from %ListOfDataTypes and %SetSerial does the reverse.
Both of these methods are private though. You can subclass %ListOfDataTypes and publish them.
Oh great!
Please InterSystems developers, make these useful methods public and supported ;-)
You can request new features/enhancements in WRC tickets.
%Collection.ListOfDT
Serialize and deserialize methods seem like doing the trick.But I found the documentation is a little bit ambiguous as the sample in the header refers itself to
%ListOfDataTypes
.https://docs.intersystems.com/iris20201/csp/documatic/%25CSP.Documatic.c...
%Collection classes are internal and not to be used.
You're sure about that?
I understand these methods should only be used when the list property comes from a
%Persistent
object, but new instance with %New method is not allowed.Well, %Collection classes are the implementation of these constructs:
You can call their methods but do not explicitly create objects of these classes.
And you can request it here in case you don't have WRC account or/if you want to make it public and get votes.
For example (in open exchange package ks-iris-lib) :
/// list of data types exposing %GetSerial and %SetSerial Class ks.lib.collections.ListOfDataTypes Extends %Library.ListOfDataTypes { /// serialize object Method %GetSerial(force As %Integer = 0) As %String { return ##super(force) } /// deserialize object Method %SetSerial(serialized As %String) As %Status { return ##super(.serialized) } Storage Custom { <Type>%Library.CompleteCustomStorage</Type> } }