PDA

View Full Version : Serving up and formatting JSON from an RSP page



hmischel@diligentsystems.com
2015-03-26, 08:17
It is incredibly easy to serve up a json result set in Lianja. I was overcomplicating it, so thought some others might be doing the same (again - I turned to Yvonne and Barry for assistance).

Here is the entire RSP page. It takes a parameter, gets the data, cleans it up, and delivers.

Herb

<%@ language=VFP %>
<%
private m_term = lower( getParameter("term", "") )
private aresult
set strcompare off
select contactname from southwind!customers where lower(contactname) = m_term into array aresult

m= json_encode(aresult)
m=strtran(m,"[[","[")
m=strtran(m,"]]","]")
m=strtran(m,"],[",",")
echo m

%>