set json to "{\"items\": [" & return & return
repeat with itemRef in a
set r to contents of itemRef
set json to json & tab & "{" & return
if not q_is_empty(theUid of r) then
set json to json & tab2 & "\"uid\": \"" & encode(theUid of r) & "\"," & return
end if
set json to json & tab2 & "\"valid\": \"" & my encode(isValid of r) & "\"," & return
set json to json & tab2 & "\"title\": \"" & my encode(theTitle of r) & "\"," & return
set json to json & tab2 & "\"subtitle\": \"" & my encode(theSubtitle of r) & "\"," & return
set json to json & tab2 & "\"arg\": \"" & my encode(theArg of r) & "\"," & return
if not q_is_empty(theAutocomplete of r) then
set json to json & tab2 & "\"autocomplete\": \"" & my encode(theAutocomplete of r) & "\"," & return
end if
if not q_is_empty(theQuicklook of r) then
set json to json & tab2 & "\"quicklookurl\": \"" & my encode(theQuicklook of r) & "\"," & return
end if
if not q_is_empty(theIcon of r) then
set ic to theIcon of r
set json to json & tab2 & "\"icon\": {" & return
if not q_is_empty(theType of ic) then
set json to json & tab3 & "\"type\": \"" & my encode(theType of ic) & "\"," & return
end if
if not q_is_empty(thePath of ic) then
set json to json & tab3 & "\"path\": \"" & my encode(thePath of ic) & "\"" & return
end if
set json to json & tab2 & "}," & return