Created
          February 12, 2016 14:05 
        
      - 
      
 - 
        
Save knight-of-ni/a95dbce990d36a6a438d to your computer and use it in GitHub Desktop.  
    jsonencode
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [["1","Monitor-1","Local","None","320","240","3","0.00","0.00"],["2","Monitor-2","File","Monitor","328","208","3","1.00","1.00"],["3","Foscam9821Demo","Ffmpeg","None","1280","720","4","31.00","31.00"],["4","remote_cam","Remote","Monitor","640","360","4","0.00","0.00"]] | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
use JSON;
use ZoneMinder;
my $dbh = zmDbConnect();
my $sql = "SELECT Id,Name,Type,Function,Width,Height,Colours,MaxFPS,AlarmMaxFPS FROM Monitors";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
my $arrayref = $sth->fetchall_arrayref({});
my $jsonmsg = encode_json ( $arrayref );
print $jsonmsg;
[{"Id":"1","Name":"DoorCamera","Type":"Ffmpeg","Function":"Mocord","AlarmMaxFPS":"0.00","MaxFPS":"20.00","Width":"1280","Height":"720","Colours":"4"},{"MaxFPS":"20.00","Height":"960","Width":"1280","Name":"Garage","Id":"2","Type":"Remote","Function":"Modect","AlarmMaxFPS":"0.00","Colours":"4"},{"AlarmMaxFPS":"0.00","Name":"Basement","Id":"3","Type":"Remote","Function":"Modect","Width":"1280","Height":"960","MaxFPS":"20.00","Colours":"4"},{"Colours":"4","Id":"4","Name":"FirstLevel","Type":"Remote","Function":"Monitor","AlarmMaxFPS":"0.00","MaxFPS":"20.00","Height":"960","Width":"1280"},{"Colours":"3","AlarmMaxFPS":"0.00","Name":"Unfinished","Id":"5","Type":"Remote","Function":"Modect","Width":"640","Height":"480","MaxFPS":"20.00"},{"Colours":"4","AlarmMaxFPS":"0.00","Id":"6","Name":"BabyRoom","Type":"Remote","Function":"Monitor","Width":"1280","Height":"720","MaxFPS":"20.00"}]