import module namespace json = "http://www.zorba-xquery.com/modules/converters/json"; import module namespace file = "http://expath.org/ns/file"; let $rec := key this is my "val" indeed. I also have single'quotes. Here is a newline. And here: is a tab character. I have a backslash \, a forward slash /. Here are some entities: double-quotes " less-then < greater-than > ampersand & apostrophe ' And here are character references: bell  ; formfeed return file:write( "output.txt", json:serialize($rec, ), () )