Creating a specific python dictionary
Question: Re-asking clearly my question : I want to produce this json output using
flask.jsonify, how can I build the corresponding dictionary to do so ?

    
    
    {
      "cluster": {
        "members": [
          {
            "name": "host1",
            "disks": [
              {
                "fstype": "btrfs",
                "size": "62G",
                "status": "up"
              },
              {
                "fstype": "btrfs",
                "size": "260G",
                "status": "up"
              },
              {
                "fstype": "btrfs",
                "size": "263G",
                "status": "up"
              },
              {
                "fstype": "btrfs",
                "size": "257G",
                "status": "up"
              }
            ]
          },
          {
            "name": "host2",
            "disks": [
              {
                "fstype": "btrfs",
                "size": "66G",
                "status": "up"
              },
              {
                "fstype": "btrfs",
                "size": "259G",
                "status": "up"
              }
            ]
          },
          {
            "name": "host3",
            "disks": [
              {
                "fstype": "btrfs",
                "size": "62G",
                "status": "up"
              },
              {
                "fstype": "btrfs",
                "size": "259G",
                "status": "up"
              },
              {
                "fstype": "btrfs",
                "size": "257G",
                "status": "up"
              },
              {
                "fstype": "btrfs",
                "size": "263G",
                "status": "up"
              }
            ]
          }
        ],
        "name": "MyCluster1",
        "status": "HEALTH_OK"
      }
    }
    

Re-asking clearly my question : I want to produce this json output using
flask.jsonify, how can I build the corresponding dictionary to do so ?


Answer: If your long text field is a string called 'text', then you can load it as a
json object like this:

    
    
    import json
    new = json.loads(text)
    

