Use python to convert dict1 to dict2, in the example. I tried for a long time but couldn't find a solution.

dict1 = {
        "system.cpu.user.pct": {
            "value": 12.83
          },
          "system.load.1": {
            "value": 0.33
          }
}

dict2 = {
        "system": {
                "cpu": {
                        "user": {
                                "pct": 12.83
                        }
                },
            "load": {
                        "1": 0.33
                }
        }
}

after doing it for a few days, I finally took care of it myself, or I was too lame. Here is my solution:

import json
def add_key(dict, field):
    keys = field.split(".")
    length = len(keys)
    number = 0
    for key in keys:
        if number != length - 1:
            dict = dict.setdefault(key, {})
        else:
            dict[key] = dict1[field]["value"]
        number += 1

report = {}
for field in dict1.keys():
    add_key(report, field)
print report
Feb.26,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-e35ce0-88e7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-e35ce0-88e7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?