Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my ($first, $max, $count) = (0, 1000, 1000);
- while ($count == $max) {
- my $debugFlag = 1;
- my $uri = "/webacs/api/v2/data/Devices.json?.full=true&.nocount=true&" .
- ".firstResult=$first&.maxResults=$max";
- $piConnection->GET($uri, $headers);
- my $response = decode_json $piConnection->responseContent();
- $first = $first + 1000;
- $count = scalar @{$response->{queryResponse}{entity}};
- firstResult = 0
- maxResults = 1000
- count = 1000
- while count == maxResults:
- test_urn = (URL + '/webacs/api/v2/data/Devices?.full=True&.nocount=True&.maxResults=%d&.firstResult=%d') % (maxResults, firstResult)
- get_response = requests.get(test_urn, verify=False)
- firstResult = firstResult + 1000
- count = len(get_response['queryResponse']) # This is the line I need help with
- print get_response.text
- use JSON::XS qw( decode_json );
- my $response_json = '{ "queryResponse": { "entity": [ "a", "b", "c" ] } }';
- my $response = decode_json($response_json);
- my $count = @{ $response->{queryResponse}{entity} };
- import json
- response_json = '{ "queryResponse": { "entity": [ "a", "b", "c" ] } }'
- response = json.loads(response_json)
- count = len(response['queryResponse']['entity'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement