Skip to content

Instantly share code, notes, and snippets.

@apb2006
Created December 2, 2014 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apb2006/2f1a6ec32de4b0aefcdd to your computer and use it in GitHub Desktop.
Save apb2006/2f1a6ec32de4b0aefcdd to your computer and use it in GitHub Desktop.
BaseX RESTXQ JSON test
(:~
: JSON test apb 2dec 2014
:)
module namespace page = 'json-test';
declare variable $page:data:=<json objects="json _">
<total type="number">15</total>
<entity>app</entity>
<items type="array">
<_>
<logo type="string">/static/abide/logo.svg</logo>
<name type="string">abide</name>
<uri type="string">/abide</uri>
<description type="string">todo this</description>
</_>
</items>
</json>
;
declare %rest:path("/json") %output:method("json")
function page:json(){ $page:data}
;
declare %rest:path("/json2") %output:method("text")
function page:json2(){json:serialize($page:data)}
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment