c# - Parsing nested dictionary with LINQ -
i have json object deserializing using newtonsoft.json dictionary<string, dictionary<string, string>>
i want parse dictionary<string, dictionary<double, int>>
using linq struggling nested part.
for un-nested dictionaries using .todictionary(k => double.parse(k.key), k => int.parse(k.value))
thanks
var input = new dictionary<string, dictionary<string, string>>(); input.add("test1", new dictionary<string, string>()); input["test1"].add("1.2", "3"); var output = input.todictionary( x => x.key, x => x.value.todictionary( y => double.parse(y.key), y => int.parse(y.value) ) );
should trick.
Comments
Post a Comment