diff --git a/apiprinters.asp b/apiprinters.asp index cbc27f1..3f0548b 100644 --- a/apiprinters.asp +++ b/apiprinters.asp @@ -15,7 +15,8 @@ Response.AddHeader "Expires", "0" Dim strSQL, rs, jsonOutput, isFirst strSQL = "SELECT p.printerid, p.printerwindowsname, p.printercsfname, p.fqdn, p.ipaddress, " & _ - "v.vendor, m.modelnumber, p.isactive, ma.alias, ma.machinenumber, p.installpath " & _ + "v.vendor, m.modelnumber, p.isactive, ma.alias, ma.machinenumber, p.installpath, " & _ + "p.mapleft, p.maptop " & _ "FROM printers p " & _ "LEFT JOIN models m ON p.modelid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ @@ -159,6 +160,25 @@ Do While Not rs.EOF jsonOutput = jsonOutput & vbCrLf & " ""modelnumber"": """ & model & """," jsonOutput = jsonOutput & vbCrLf & " ""machinename"": """ & machineName & """," jsonOutput = jsonOutput & vbCrLf & " ""installpath"": """ & installPath & """," + + ' mapleft / maptop are nullable INTs (pixel coords on the site map + ' for printerinstallermap.asp + PrinterInstallerMap.exe). Emit JSON + ' literal null when the column is NULL so consumers can detect "no + ' map coords for this printer" without resorting to magic numbers. + Dim mapLeftVal, mapTopVal + If IsNull(rs("mapleft")) Then + mapLeftVal = "null" + Else + mapLeftVal = CStr(rs("mapleft")) + End If + If IsNull(rs("maptop")) Then + mapTopVal = "null" + Else + mapTopVal = CStr(rs("maptop")) + End If + jsonOutput = jsonOutput & vbCrLf & " ""mapleft"": " & mapLeftVal & "," + jsonOutput = jsonOutput & vbCrLf & " ""maptop"": " & mapTopVal & "," + jsonOutput = jsonOutput & vbCrLf & " ""isactive"": " & LCase(CStr(CBool(rs("isactive")))) jsonOutput = jsonOutput & vbCrLf & " }" End If