[ 
https://issues.apache.org/jira/browse/THRIFT-5309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17234846#comment-17234846
 ] 

Darius Jankauskas commented on THRIFT-5309:
-------------------------------------------

I just made a generic method with 1 level nested TMap
{code:java}
    static func nestedDictionary<T1,T2,T3>(from thriftDict: TMap<T1, TMap<T2, 
T3>>) -> [T1:[T2:T3]] {
        var result = [T1:[T2:T3]]()
        
        for (key, value) in thriftDict {
            result[key] = value.dictionary
        }
        return result
    }
{code}

> Converting nested TMap into Dictionary
> --------------------------------------
>
>                 Key: THRIFT-5309
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5309
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Swift - Library
>            Reporter: Darius Jankauskas
>            Priority: Minor
>
> I find myself writing a lot of code to convert a nested TMap back into normal 
> nested Dictionary. For example:
>  
> {code:java}
> let thriftDict: TMap<String, TMap<Int64, Double>> // given this
> var result = [String:[Int64:Double]]()
> for (key, value) in thriftDict {
>     result[key] = value.dictionary
> }
> {code}
> Having TMap to begin with seems very un-Swifty but I realise getting rid of 
> it is probably too big of a task at this point.
> I wonder if there's a way to make the above code generic and include in the 
> TMap implementation as `dictionaryDeepCopy`.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to