Skip to content

output as json #33

@suslikas

Description

@suslikas

Hi,

Ease for any just put out what you get, then any who will use you code can make decision with output format better: json, xml, or just re-parse to k:v plain text.

Example:

    @property                                                   
    def get_json_system(self):                                  
        self._check_login()                                     
        response = self._do_get("{}/{}".format(self._api_url, "types/System/instances")).json()
        return response                                         

    def get_json_system_relationships_statistics(self, id):
        self._check_login()
        response = self._do_get("{}/{}".format(self._api_url, "instances/System::" + id + "/relationships/Statistics")).json()
        return response
system_id = sio.get_json_system[0]['id']
totalwritebwc = sio.get_json_system_relationships_statistics(system_id)['totalWriteBwc']
print json.dumps(totalwritebwc)

Result:

python /root/scio.py | jq
{
  "numOccured": 12612,
  "numSeconds": 5,
  "totalWeightInKb": 264807
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions