如何把 Java properties 转换为具有层级结构的字典

如何把 Java properties 转换为具有层级结构的字典

java.class.version = 60.0
java.home = /usr/lib/jvm/java-16-openjdk
java.runtime.name = OpenJDK Runtime Environment
java.runtime.version = 16.0.2+7
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 16
java.vendor = N/A
java.vendor.url = https://openjdk.java.net/
java.vendor.url = https://openjdk.java.net/
java.vendor.url.bug = https://bugreport.java.com/bugreport/
java.vendor.url.bug = https://bugreport.java.com/bugreport/
java.vendor.url.bug = https://bugreport.java.com/bugreport/
java.version = 16.0.2
java.version.date = 2021-07-20
java.vm.name = OpenJDK 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 16
java.vm.vendor = Oracle Corporation
java.vm.version = 16.0.2+7
sun.arch.data.model = 64

我用 javaproperties 模块把上面内容转换成了字典:

{'java.class.version': '60.0',
 'java.home': '/usr/lib/jvm/java-16-openjdk',
 'java.runtime.name': 'OpenJDK Runtime Environment',
 'java.runtime.version': '16.0.2+7',
 'java.specification.name': 'Java Platform API Specification',
 'java.specification.vendor': 'Oracle Corporation',
 'java.specification.version': '16',
 'java.vendor': 'N/A',
 'java.vendor.url': 'https://openjdk.java.net/',
 'java.vendor.url.bug': 'https://bugreport.java.com/bugreport/',
 'java.version': '16.0.2',
 'java.version.date': '2021-07-20',
 'java.vm.name': 'OpenJDK 64-Bit Server VM',
 'java.vm.specification.name': 'Java Virtual Machine Specification',
 'java.vm.specification.vendor': 'Oracle Corporation',
 'java.vm.specification.version': '16',
 'java.vm.vendor': 'Oracle Corporation',
 'java.vm.version': '16.0.2+7',
 'sun.arch.data.model': '64'}

但是我想根据这些 properties 的键中相同的部分,把它转换成具有层级结构的字典,类似于:

{
    'java': {
        'class': {
            'version': 60.0
        },
        'home': '/usr/lib/jvm/java-16-openjdk',
        'runtime': {
            'name': 'OpenJDK Runtime Environment',
            'version': '16.0.2+7'
        },
        'specification': {
            'name': 'Java Platform API Specification',
            'vendor': 'Oracle Corporation',
            'verison': 16
        },
        ...: ...  # 省略剩余的内容
    },
    'sun': {
        'arch': {
            'data': {
                'model': 64
            }
        }
    }
}

有没有第三方库方便进行转换?或者如果自己造轮子,提供一个思路?