Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
Convert String to Assoc
Vadim_Tchebotarev_(ebuild01user1_-_(deleted))
Hello,I have a quick question:How to convert a sequence of strings to an Assoc?For example:String s = " 'name'='Ala', 'name2'='O''Hara', 'zz'='ula,bula' "Assoc a = ConvertToAssoc(s)How to create such a ConvertToAssoc() function?Thanks for any hints,L
Find more posts tagged with
Comments
Alex_Kowalenko_(x-eu0016039_-_(deleted))
You might try something like this, assuming your pair-value delimeters are ", ":function Assoc ConvertToAssoc( \ String stringValues = " 'name'='Ala', 'name2'='O''Hara', 'zz'='ula,bula' " ) Assoc assocValues String stringElement List pairElement List stringElements String delim = Str.Ascii( 1 ) String quote = "'" String quote2 = "''" String sep = ", " String equal = '=' stringElements = Str.Elements( Str.ReplaceAll( stringValues, sep, delim ), delim ) for stringElement in stringElements pairElement = Str.Elements( Str.Trim( stringElement ), equal ) assocValues.( Str.Strip( Str.Trim( pairElement[ 1 ] ), quote ) ) = \ Str.ReplaceAll( \ Str.Strip( \ Str.ReplaceAll( Str.Trim( pairElement[ 2 ] ), quote2, delim ), \ quote ), \ delim, quote ) end return assocValues end
Vadim_Tchebotarev_(ebuild01user1_-_(deleted))
Thanks Alex,But what about the case when we have ", " as a part of the string? For example:String s = " 'name'='Wania, Kluska', 'ooo'='i' "In this case the ", " inside 'Wania, Kluska' will be treated as a separator. I need a more generic solution.Actually I was thinking about a kind of "Assoc Parser". I would provide a string:s = "A<?,1,'name'='Ala','name2'='O''Hara','zz'='ula,bula'>"and the parser would create an Assoc from it. In other words it would evaluate the string as an Assoc.Any suggestions?L
David_Caughell
Message from David Caughell via eLinkIf you are creating a string version of the Assoc, then this should workfor you:Assoc a = Str.StringToValue(s) David.> -----Original Message-----> From: eLink Discussion: Development Discussion > [mailto:development@elinkkc.opentext.com] > Sent: September 30, 2005 11:44 AM> To: eLink Recipient> Subject: I need a more generic solution> > I need a more generic solution> Posted by Tchebotarev, Vadim on 09/30/2005 11:40 AM> > Thanks Alex,> > But what about the case when we have ", " as a part of the > string? For example:> String s = " 'name'='Wania, Kluska', 'ooo'='i' "> > In this case the ", " inside 'Wania, Kluska' will be treated > as a separator. I need a more generic solution.> > Actually I was thinking about a kind of "Assoc Parser". I > would provide a string:> s = "A<?,1,'name'='Ala','name2'='O''Hara','zz'='ula,bula'>"> > and the parser would create an Assoc from it. In other words > it would evaluate the string as an Assoc.> > Any suggestions?> > L> > > > [To reply to this thread, use your normal E-mail reply function.]> > ============================================================> > Topic: Convert String to Assoc>
https://knowledge.opentext.com/knowledge/livelink.exe/open/4199325>
; > Discussion: Development Discussion>
https://knowledge.opentext.com/knowledge/livelink.exe/open/786303>
; > Livelink Server:>
https://knowledge.opentext.com/knowledge/livelink.exe>
; > To Unsubscribe from this Discussion, send an e-mail to > unsubscribe.development@elinkkc.opentext.com.> > >
Alex_Kowalenko_(x-eu0016039_-_(deleted))
Message from Alex Kowalenko via eLinkDavid's suggestion is apropos if you have control over the stringformatting. Examine the syntax of a string-encoded assoc, create your stringin that model and just use the built-in Str.StringToValue function.-alex------Original Message-----From: eLink Discussion: Development Discussion[mailto:development@elinkkc.opentext.com] Sent: Friday, September 30, 2005 12:04 PMTo: eLink RecipientSubject: RE I need a more generic solutionRE I need a more generic solutionPosted by Caughell, David on 09/30/2005 12:04 PMMessage from David Caughell via eLinkIf you are creating a string version of the Assoc, then this should workfor you:Assoc a = Str.StringToValue(s) David.> -----Original Message-----> From: eLink Discussion: Development Discussion > [mailto:development@elinkkc.opentext.com] > Sent: September 30, 2005 11:44 AM> To: eLink Recipient> Subject: I need a more generic solution> > I need a more generic solution> Posted by Tchebotarev, Vadim on 09/30/2005 11:40 AM> > Thanks Alex,> > But what about the case when we have ", " as a part of the > string? For example:> String s = " 'name'='Wania, Kluska', 'ooo'='i' "> > In this case the ", " inside 'Wania, Kluska' will be treated > as a separator. I need a more generic solution.> > Actually I was thinking about a kind of "Assoc Parser". I > would provide a string:> s = "A<?,1,'name'='Ala','name2'='O''Hara','zz'='ula,bula'>"> > and the parser would create an Assoc from it. In other words > it would evaluate the string as an Assoc.> > Any suggestions?> > L> > > > [To reply to this thread, use your normal E-mail reply function.]> > ============================================================> > Topic: Convert String to Assoc>
https://knowledge.opentext.com/knowledge/livelink.exe/open/4199325>
; > Discussion: Development Discussion>
https://knowledge.opentext.com/knowledge/livelink.exe/open/786303>
; > Livelink Server:>
https://knowledge.opentext.com/knowledge/livelink.exe>
; > To Unsubscribe from this Discussion, send an e-mail to > unsubscribe.development@elinkkc.opentext.com.> > >[To reply to this thread, use your normal E-mail reply function.]============================================================Topic: Convert String to Assoc
https://knowledge.opentext.com/knowledge/livelink.exe/open/4199325Discussion
: Development Discussion
https://knowledge.opentext.com/knowledge/livelink.exe/open/786303Livelink
Server:
https://knowledge.opentext.com/knowledge/livelink.exeTo
Unsubscribe from this Discussion, send an e-mail tounsubscribe.development@elinkkc.opentext.com.
Vadim_Tchebotarev_(ebuild01user1_-_(deleted))
Str.StringToValue is the answer for my problem.Thanks a lot!L
Michael_Gao_(enbinc01user6_-_(deleted))
Is there someway to do the same thing in LAPI?