Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. my ($first, $max, $count) = (0, 1000, 1000);
  2.  
  3. while ($count == $max) {
  4. my $debugFlag = 1;
  5. my $uri = "/webacs/api/v2/data/Devices.json?.full=true&.nocount=true&" .
  6. ".firstResult=$first&.maxResults=$max";
  7. $piConnection->GET($uri, $headers);
  8. my $response = decode_json $piConnection->responseContent();
  9. $first = $first + 1000;
  10. $count = scalar @{$response->{queryResponse}{entity}};
  11.  
  12. firstResult = 0
  13. maxResults = 1000
  14. count = 1000
  15.  
  16. while count == maxResults:
  17. test_urn = (URL + '/webacs/api/v2/data/Devices?.full=True&.nocount=True&.maxResults=%d&.firstResult=%d') % (maxResults, firstResult)
  18. get_response = requests.get(test_urn, verify=False)
  19. firstResult = firstResult + 1000
  20. count = len(get_response['queryResponse']) # This is the line I need help with
  21. print get_response.text
  22.  
  23. use JSON::XS qw( decode_json );
  24. my $response_json = '{ "queryResponse": { "entity": [ "a", "b", "c" ] } }';
  25. my $response = decode_json($response_json);
  26. my $count = @{ $response->{queryResponse}{entity} };
  27.  
  28. import json
  29. response_json = '{ "queryResponse": { "entity": [ "a", "b", "c" ] } }'
  30. response = json.loads(response_json)
  31. count = len(response['queryResponse']['entity'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement