<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.toJsonString.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.toJsonString</api:function-name><api:suggest>xdmp.tojsonstring</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>tojsonstring</api:suggest><api:function-link mode="xquery" fullname="xdmp:to-json-string">/apidoc/8.0/xdmp:to-json-string.xml</api:function-link><api:function mode="javascript" name="toJsonString" type="builtin" lib="xdmp" category="Extension" subcategory="JSON" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.toJsonString"><api:summary>
  Returns a string representing a JSON
  serialization of a given item sequence.
</api:summary><api:params><api:param name="item" type="item()*"><api:param-description>
    The item sequence whose JSON serialization is returned.
  </api:param-description><api:param-name>item</api:param-name><api:param-type>ValueIterator</api:param-type></api:param></api:params><api:return>String</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">XML nodes are serialized to JSON strings.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">JSON has no serialization for infinity, not a number, and negative 0,
  therefore if you try and serialize INF, -INF, NaN, or -0 as JSON, an
  exception is thrown.  If you want to represent these values in some way in
  your serialized JSON, then you can catch the exception (with a try/catch, for
  example) and provide your own value for it.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">XQuery maps (<code>map:map</code> types) serialize to JSON name-value
  pairs.</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  xdmp.toJsonString(["a",false]);
   =&gt; ["a", false]
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.toJsonString(
  xdmp.fromJsonString('{ "a":111 }'));
=&gt;
{"a":111}
</pre></api:example></api:function></api:function-page>