Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: toJSONPage2 Arguments: data Description: Converts a data object into a JSON string, and returns a page with the data. Page type: webl Render function: Module: siteutil Page source: var res = ""; var GetValue; var Body = fun(spc, data) var res = ""; var comma = ""; if Objectp(data) then res = res + "{"; every field in ToList(data) do res = res + comma + `"` + field + `": ` + GetValue(spc + " ", data[field]); comma = ", " end; res = res + "}" elsif Listp(data) then res = res + "["; every obj in data do res = res + comma + GetValue(spc + " ", obj); comma = ", " end; res = res + "]" end; res end; GetValue = fun(spc, value) var res = ""; if Objectp(value) or Listp(value) then res = Body(spc, value) elsif Intp(value) then res = ToString(value) else res = `"` + ToString(value) + `"` end; res end; res = res + Body("", data); res = Wub_ReplaceAll(res, "\n", `\n`); NewPage(res, "text/plain"); // ToString(data);