set json to json & tab2 & "\"variables\" : {" & return
repeat with v in theVars of r
set varName to |name| of v
set varVal to value of v
set json to json & tab3 & "\"" & my encode(varName) & "\": \"" & my encode(varVal) & "\"," & return
end repeat
set json to json & tab2 & "}," & return