def printClass(info, name, level = 0):
    subdicts = []

    print('\t' * level + 'struct %s: JSONDecodable {' % name)
    for key, value in info.iteritems():
        fieldName = toCamelCase(key, False)
        comment = '' if fieldName == key else '// json:"%s"' % key
        typename = toCamelCase(key)

        if type(value) == dict:
            subdicts.append((value, typename))
        elif type(value) == list:
            assert(len(value) == 1)
            subdicts.append((value[0], typename))
            typename = '[' + typename + ']'
        else:
            typename = guessTypenameFromSet(value)

        print('\t' * (level+1) + 'let %-20s: %-20s %s' % (fieldName, typename, comment))

    if len(subdicts) > 0:
        print()
        map(lambda e: printClass(e[0], e[1], level + 1), subdicts)
    print('\t' * level + '}')
dataset/ETHPy150Open safx/swift-idl/json2idl.py/printClass/original