Could anyone tell me how to iterate over a nested dictionary and replace the keys which have underscore and are in small letters ,to keys without underscore and camelcase.
Final dictionary should have keys without underscore and should be camelcase.
the logic i wrote is
d is the dictionary...
def printDict(d):
for oldkey, v in d.iteritems():
if type(v) is dict:
newkey=camel_case(old_key)
d[newkey]=d.pop[oldkey]
printDict(v)
else:
for oldkey, w in d.iteritems():
newkey=camel_case(old_key)
d[newkey]=d.pop[oldkey]
def camel_case(string)
title=string.title().replace("_","")
ca,el=title[0].lower+title[1:]
Final dictionary should have keys without underscore and should be camelcase.
the logic i wrote is
d is the dictionary...
def printDict(d):
for oldkey, v in d.iteritems():
if type(v) is dict:
newkey=camel_case(old_key)
d[newkey]=d.pop[oldkey]
printDict(v)
else:
for oldkey, w in d.iteritems():
newkey=camel_case(old_key)
d[newkey]=d.pop[oldkey]
def camel_case(string)
title=string.title().replace("_","")
ca,el=title[0].lower+title[1:]