Here is a super simple sample of generating JSON output. One way to use this is to create a page and call it from owsFetch or jQuery.ajax. This works well with many (all?) of the jQuery plug-ins that can consume JSON data.
Hope this helps!
New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seattle, WA • firstname.lastname@example.org