← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1200090 into lp:zorba

 

Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/bug-1200090 into lp:zorba.

Commit message:
Now converting json-items to/from XDM and no longer converting to/from strings.

Requested reviews:
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #1200090 in Zorba: "Convert json-xml module to use JSONiq items"
  https://bugs.launchpad.net/zorba/+bug/1200090

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1200090/+merge/177233

Now converting json-items to/from XDM and no longer converting to/from strings.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1200090/+merge/177233
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2013-07-12 00:43:14 +0000
+++ ChangeLog	2013-07-26 23:55:36 +0000
@@ -45,6 +45,7 @@
   * Fixed bug #1188100 (regex issues with 'q' flag in fn:tokenize)
   * Fixed invalid memory access error occuring during sequence type matching
     for user-defined types.
+  * Fixed bug #1200090 (Convert json-xml module to use JSONiq items)
   * API change - Fixed bug #938574 (changed the names and semantics of the NsScoping enum)
   * Fixed bug #1190710 (fn-format-date failures)
   * Fixed bug #1190407 (wrong rewrite of if-then-else return clause in case

=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
--- include/zorba/pregenerated/diagnostic_list.h	2013-06-25 00:41:44 +0000
+++ include/zorba/pregenerated/diagnostic_list.h	2013-07-26 23:55:36 +0000
@@ -874,15 +874,15 @@
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0003_BAD_ATTRIBUTE_VALUE;
 
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0004_BAD_ELEMENT;
-
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0005_BAD_CHILD_ELEMENT;
-
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0006_NO_ELEMENT_CHILD;
-
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0007_NO_TEXT_CHILD;
-
-extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0008_BAD_VALUE;
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0004_BAD_NODE;
+
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0007_ELEMENT_MISSING_VALUE;
+
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0008_BAD_ELEMENT_VALUE;
+
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0009_MULTIPLE_CHILDREN;
+
+extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJ2X0001_JSONML_ARRAY_BAD_JSON;
 
 extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS;
 

=== modified file 'modules/json/json-xml.xq'
--- modules/json/json-xml.xq	2013-07-11 00:46:02 +0000
+++ modules/json/json-xml.xq	2013-07-26 23:55:36 +0000
@@ -1,3 +1,5 @@
+xquery version "3.0";
+
 (:
  : Copyright 2006-2009 The FLWOR Foundation.
  :
@@ -14,85 +16,83 @@
  : limitations under the License.
  :)
 
-xquery version "3.0";
-
- (:~
-  : Using this module, you can parse JSON data into XML, manipulate it like any
-  : other XML data using XQuery, and serialize the result back as JSON.<p/>
-  :
-  : There are many ways to represent JSON data in XML, some loss-less ("round
-  : tripable") and some lossy ("one way").  Loss-less representations preserve
-  : the JSON data types <i>boolean</i>, <i>number</i>, and <i>null</i>; lossy
-  : representations convert all data to strings.
-  : <p/>
-  : For a loss-less representation, Zorba implements that proposed by
-  : <a href="http://john.snelson.org.uk/parsing-json-into-xquery";>John Snelson</a>.
-  : For example:
-  : <pre>
-  :   {
-  :     "firstName" : "John",
-  :     "lastName" : "Smith",
-  :     "address" : {
-  :       "streetAddress" : "21 2nd Street",
-  :       "city" : "New York",
-  :       "state" : "NY",
-  :       "postalCode" : 10021
-  :     },
-  :     "phoneNumbers" : [ "212 732-1234", "646 123-4567" ]
-  :   }
-  : </pre>
-  : would be represented as:
-  : <pre>
-  :   &lt;json type="object"&gt;
-  :     &lt;pair name="firstName" type="string"&gt;John&lt;/pair&gt;
-  :     &lt;pair name="lastName" type="string"&gt;Smith&lt;/pair&gt;
-  :     &lt;pair name="address" type="object"&gt;
-  :       &lt;pair name="streetAddress" type="string"&gt;21 2nd Street&lt;/pair&gt;
-  :       &lt;pair name="city" type="string"&gt;New York&lt;/pair&gt;
-  :       &lt;pair name="state" type="string"&gt;NY&lt;/pair&gt;
-  :       &lt;pair name="postalCode" type="number"&gt;10021&lt;/pair&gt;
-  :     &lt;/pair&gt;
-  :     &lt;pair name="phoneNumbers" type="array"&gt;
-  :       &lt;item type="string"&gt;212 732-1234&lt;/item&gt;
-  :       &lt;item type="string"&gt;646 123-4567&lt;/item&gt;
-  :     &lt;/pair&gt;
-  :   &lt;/json&gt;
-  : </pre>
-  : For a lossy representation, Zorba implements
-  : <a href="http://jsonml.org/";>JsonML</a> (the array form).
-  : For example:
-  : <pre>
-  :   [ "person",
-  :     { "created" : "2006-11-11T19:23",
-  :       "modified" : "2006-12-31T23:59" },
-  :     [ "firstName", "Robert" ],
-  :     [ "lastName", "Smith" ],
-  :     [ "address",
-  :       { "type" : "home" },
-  :       [ "street", "12345 Sixth Ave" ],
-  :       [ "city", "Anytown" ],
-  :       [ "state", "CA" ],
-  :       [ "postalCode", "98765-4321" ]
-  :     ]
-  :   ]
-  : </pre>
-  : would be represented as:
-  : <pre>
-  :   &lt;person created="2006-11-11T19:23" modified="2006-12-31T23:59"&gt;
-  :     &lt;firstName&gt;Robert&lt;/firstName&gt;
-  :     &lt;lastName&gt;Smith&lt;/lastName&gt;
-  :     &lt;address type="home"&gt;
-  :       &lt;street&gt;12345 Sixth Ave&lt;/street&gt;
-  :       &lt;city&gt;Anytown&lt;/city&gt;
-  :       &lt;state&gt;CA&lt;/state&gt;
-  :       &lt;postalCode&gt;98765-4321&lt;/postalCode&gt;
-  :     &lt;/address&gt;
-  :   &lt;/person&gt;
-  : </pre>
-  :
-  : @author Paul J. Lucas
-  : @project Zorba/Data Converters/JSON
-  :)
+(:~
+ : Using this module, you can parse JSON data into XML, manipulate it like any
+ : other XML data using XQuery, and serialize the result back as JSON.<p/>
+ :
+ : There are many ways to represent JSON data in XML, some loss-less ("round
+ : tripable") and some lossy ("one way").  Loss-less representations preserve
+ : the JSON data types <i>boolean</i>, <i>number</i>, and <i>null</i>; lossy
+ : representations convert all data to strings.
+ : <p/>
+ : For a loss-less representation, this module implements that proposed by
+ : <a href="http://john.snelson.org.uk/parsing-json-into-xquery";>John Snelson</a>.
+ : For example:
+ : <pre>
+ :   {
+ :     "firstName" : "John",
+ :     "lastName" : "Smith",
+ :     "address" : {
+ :       "streetAddress" : "21 2nd Street",
+ :       "city" : "New York",
+ :       "state" : "NY",
+ :       "postalCode" : 10021
+ :     },
+ :     "phoneNumbers" : [ "212 732-1234", "646 123-4567" ]
+ :   }
+ : </pre>
+ : would be represented as:
+ : <pre>
+ :   &lt;json type="object"&gt;
+ :     &lt;pair name="firstName" type="string"&gt;John&lt;/pair&gt;
+ :     &lt;pair name="lastName" type="string"&gt;Smith&lt;/pair&gt;
+ :     &lt;pair name="address" type="object"&gt;
+ :       &lt;pair name="streetAddress" type="string"&gt;21 2nd Street&lt;/pair&gt;
+ :       &lt;pair name="city" type="string"&gt;New York&lt;/pair&gt;
+ :       &lt;pair name="state" type="string"&gt;NY&lt;/pair&gt;
+ :       &lt;pair name="postalCode" type="number"&gt;10021&lt;/pair&gt;
+ :     &lt;/pair&gt;
+ :     &lt;pair name="phoneNumbers" type="array"&gt;
+ :       &lt;item type="string"&gt;212 732-1234&lt;/item&gt;
+ :       &lt;item type="string"&gt;646 123-4567&lt;/item&gt;
+ :     &lt;/pair&gt;
+ :   &lt;/json&gt;
+ : </pre>
+ : For a lossy representation, this module implements
+ : <a href="http://jsonml.org/";>JsonML</a> (the array form).
+ : For example:
+ : <pre>
+ :   [ "person",
+ :     { "created" : "2006-11-11T19:23",
+ :       "modified" : "2006-12-31T23:59" },
+ :     [ "firstName", "Robert" ],
+ :     [ "lastName", "Smith" ],
+ :     [ "address",
+ :       { "type" : "home" },
+ :       [ "street", "12345 Sixth Ave" ],
+ :       [ "city", "Anytown" ],
+ :       [ "state", "CA" ],
+ :       [ "postalCode", "98765-4321" ]
+ :     ]
+ :   ]
+ : </pre>
+ : would be represented as:
+ : <pre>
+ :   &lt;person created="2006-11-11T19:23" modified="2006-12-31T23:59"&gt;
+ :     &lt;firstName&gt;Robert&lt;/firstName&gt;
+ :     &lt;lastName&gt;Smith&lt;/lastName&gt;
+ :     &lt;address type="home"&gt;
+ :       &lt;street&gt;12345 Sixth Ave&lt;/street&gt;
+ :       &lt;city&gt;Anytown&lt;/city&gt;
+ :       &lt;state&gt;CA&lt;/state&gt;
+ :       &lt;postalCode&gt;98765-4321&lt;/postalCode&gt;
+ :     &lt;/address&gt;
+ :   &lt;/person&gt;
+ : </pre>
+ :
+ : @author Paul J. Lucas
+ : @project Zorba/Data Converters/JSON
+ :)
 module namespace jx = "http://zorba.io/modules/json-xml";;
 
 declare namespace an = "http://www.zorba-xquery.com/annotations";;
@@ -103,123 +103,105 @@
 declare option ver:module-version "1.0";
 
 (:~
- : Parses JSON data from a string and returns an XDM instance using one of the
- : representations described above.<p/>
+ : Converts JSON data into an XDM instance using one of the representations
+ : described above.<p/>
  :
- : @param $json The JSON data to parse.
- : @param $options The parsing options, for example:
+ : @param $json The JSON data.
+ : @param $options The JSON conversion  options, for example:
  : <pre>
  : { "json-format" : "JsonML-array" }
  : </pre>
  : @return said XDM instance.
- : @error zerr:ZJPE0001 if $json contains an illegal JSON character.
- : @error zerr:ZJPE0002 if $json contains an illegal Unicode code-point.
- : @error zerr:ZJPE0003 if $json contains an illegal JSON character escape.
- : @error zerr:ZJPE0004 if $json contains an illegal JSON literal.
- : @error zerr:ZJPE0005 if $json contains an illegal JSON number.
- : @error zerr:ZJPE0006 if $json is not a valid JSON string.
- : @error zerr:ZJPE0007 if $json contains an unterminated string.
- : @error zerr:ZJPE0008 if $json contains an illegal QName.
- : @example test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-array-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-object-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-jmla-j2x-01.xq
  :)
-declare function jx:json-to-xml(
-  $json as xs:string?,
-  $options as object()
-) as element(*,xs:untyped)*
+declare function jx:json-to-xml( $json as json-item()?, $options as object() )
+  as element(*,xs:untyped)?
 {
   jx:json-to-xml-internal( $json, $options )
 };
 
 (:~
- : Parses JSON data from a string and returns an XDM instance using the Snelson
- : representation described above.<p/>
+ : Converts JSON data into an XDM instance using the Snelson representation
+ : described above.<p/>
  :
- : @param $json The JSON data to parse.
+ : @param $json The JSON data.
  : @return said XDM instance.
- : @error zerr:ZJPE0001 if $json contains an illegal JSON character.
- : @error zerr:ZJPE0002 if $json contains an illegal Unicode code-point.
- : @error zerr:ZJPE0003 if $json contains an illegal JSON character escape.
- : @error zerr:ZJPE0004 if $json contains an illegal JSON literal.
- : @error zerr:ZJPE0005 if $json contains an illegal JSON number.
- : @error zerr:ZJPE0006 if $json is not a valid JSON string.
- : @error zerr:ZJPE0007 if $json contains an unterminated string.
- : @error zerr:ZJPE0008 if $json contains an illegal QName.
- : @example test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-array-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-j2x-object-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-jmla-j2x-01.xq
  :)
-declare function jx:json-to-xml(
-  $json as xs:string?
-) as element(*,xs:untyped)*
+declare function jx:json-to-xml( $json as json-item()? )
+  as element(*,xs:untyped)?
 {
-  jx:json-to-xml-internal(
-    $json, { "json-format" : "Snelson" }
-  )
+  jx:json-to-xml-internal( $json, { "json-format" : "Snelson" } )
 };
 
 (:~
- : Serializes an XDM into JSON using one of the representations described
- : above.<p/>
+ : Converts XML data into a JSON item using one of the respresentations
+ : described above.<p/>
  :
- : @param $xml The XDM to serialize.
- : @param $options The serializing options, for example:
+ : @param $xml The XML data to convert.
+ : @param $options The conversion options, for example:
  : <pre>
- : { "json-format" : "JsonML-array", "whitespace" : "indent" }
+ : { "json-format" : "JsonML-array" }
  : </pre>
- : @return a JSON string.
+ : @return said JSON items.
  : @error zerr:ZJSE0001 if $xml is not a document or element node.
  : @error zerr:ZJSE0002 if $xml contains an element that is missing a required
  : attribute.
  : @error zerr:ZJSE0003 if $xml contains an attribute having an illegal value.
  : @error zerr:ZJSE0004 if $xml contains an illegal element.
- : @error zerr:ZJSE0005 if $xml contains an illegal child element for a JSON
  : type.
- : @error zerr:ZJSE0006 if $xml contains an illegal child element.
- : @error zerr:ZJSE0007 if $xml contains an illegal text node.
+ : @error zerr:ZJSE0007 if $xml contains an element that is missing a required
+ : value.
  : @error zerr:ZJSE0008 if $xml contains an illegal value for a JSON type.
- : @example test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-array-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-object-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-jmla-x2j-01.xq
  :)
-declare function jx:xml-to-json(
-  $xml as item()*,
-  $options as object()
-) as xs:string
+declare function jx:xml-to-json( $xml as item()*, $options as object() )
+  as json-item()*
 {
   jx:xml-to-json-internal( $xml, $options )
 };
 
 (:~
- : Serializes an XDM into JSON using one of the representations described
- : above.<p/>
+ : Converts XML data into a JSON item using the Snelson representation
+ : described above.<p/>
  :
- : @param $xml The XDM to serialize.
- : @return a JSON string.
+ : @param $xml The XML data to convert.
+ : @return said JSON items.
  : @error zerr:ZJSE0001 if $xml is not a document or element node.
  : @error zerr:ZJSE0002 if $xml contains an element that is missing a required
  : attribute.
  : @error zerr:ZJSE0003 if $xml contains an attribute having an illegal value.
  : @error zerr:ZJSE0004 if $xml contains an illegal element.
- : @error zerr:ZJSE0005 if $xml contains an illegal child element for a JSON
  : type.
- : @error zerr:ZJSE0006 if $xml contains an illegal child element.
- : @error zerr:ZJSE0007 if $xml contains an illegal text node.
+ : @error zerr:ZJSE0007 if $xml contains an element that is missing a required
+ : value.
  : @error zerr:ZJSE0008 if $xml contains an illegal value for a JSON type.
- : @example test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-array-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-snelson-x2j-object-01.xq
+ : @example test/rbkt/Queries/zorba/json/json-jmla-x2j-01.xq
  :)
-declare function jx:xml-to-json(
-  $xml as item()*
-) as xs:string
+declare function jx:xml-to-json( $xml as item()* )
+  as json-item()*
 {
-  jx:xml-to-json-internal($xml, { "json-format" : "Snelson" })
+  jx:xml-to-json-internal( $xml, { "json-format" : "Snelson" } )
 };
 
 (:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
 
 declare %private function jx:json-to-xml-internal(
-  $json as xs:string?,
-  $options as item()?
+  $json as json-item()?,
+  $options as object()
 ) as element()* external;
 
-declare %an:streamable %private function jx:xml-to-json-internal(
+declare %private function jx:xml-to-json-internal(
   $xml as item()*,
-  $options as item()?
-) as xs:string external;
+  $options as object()
+) as json-item()* external;
 
 (: vim:set et sw=2 ts=2: :)

=== modified file 'modules/pregenerated/zorba-errors.xq'
--- modules/pregenerated/zorba-errors.xq	2013-06-25 00:41:44 +0000
+++ modules/pregenerated/zorba-errors.xq	2013-07-26 23:55:36 +0000
@@ -965,14 +965,6 @@
 
 (:~
 :)
-declare variable $zerr:ZJSE0005 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0005");
-
-(:~
-:)
-declare variable $zerr:ZJSE0006 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0006");
-
-(:~
-:)
 declare variable $zerr:ZJSE0007 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0007");
 
 (:~
@@ -980,6 +972,14 @@
 declare variable $zerr:ZJSE0008 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0008");
 
 (:~
+:)
+declare variable $zerr:ZJSE0009 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0009");
+
+(:~
+:)
+declare variable $zerr:ZJ2X0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZJ2X0001");
+
+(:~
  :If the opaque-part section of the URI was specified in conjuction with other non-opaque parts.
 :)
 declare variable $zerr:ZURI0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0001");

=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml	2013-06-24 23:16:24 +0000
+++ src/diagnostics/diagnostic_en.xml	2013-07-26 23:55:36 +0000
@@ -17,33 +17,33 @@
 <!--
  !  Substitutes substrings of the given string.  Substitutions are in three
  !  forms:
- ! 
+ !
  !  - $i
  !  - ${[<chars>]i[<chars>]}
  !  - $i?<then>[:<else>]
- ! 
+ !
  !  where i is a digit in the range [1,9] and refers to the value of the ith
  !  parameter, <chars> may be any characters except [1-9}], and <then> and
  !  <else> are of one of the two forms:
- ! 
+ !
  !   - j
  !   - {[<chars>]j[<chars>][k<chars>...]}
- ! 
+ !
  !  where j is likewise a digit in the range [1,9] and refers to the value of
  !  the jth parameter.
  !
  !  The first substitution form replaces $i with the value of the ith
  !  parameter.
- ! 
+ !
  !  The second form replaces everything from the $ to the } with the contents
  !  of the {} where i is replaced with the value of the ith parameter.
  !  However, if the value is empty, then everything from the $ to the } is
  !  instead erased.
- ! 
+ !
  !  For example, ${"1": } will substitute the value of the 1st parameter quoted
  !  followed by a : and a space if non-empty; if empty, then everything from
  !  the $ to the } will instead be erased.
- ! 
+ !
  !  The third form tests the value of the ith parameter: if non-empty, then the
  !  <then> portion is substituted; if empty, then the <else> portion is.  Both
  !  the <then> and <else> portions can be either a digit in the range [1,9] or
@@ -54,7 +54,7 @@
  !
  !  The \ character can be used to escape the meaning of the $, [1-9], ?, :,
  !  and } characters and instead treat them as ordinary characters.
- ! 
+ !
  !  Substitution is performed by making at most 9 passes over the string, one
  !  pass per parameter starting at 1.  Substitutions may themselves have
  !  further substitutions, but, due to the way that substitution is performed,
@@ -387,7 +387,7 @@
       </comment>
       <value>typed value of copied element or attribute node is namespace-sensitive when construction mode is preserve and copy-namespaces mode is no-preserve</value>
     </diagnostic>
-    
+
     <diagnostic code="XQTY0105">
       <comment>
         It is a type error if the content sequence in an element constructor contains a function item.
@@ -567,7 +567,7 @@
       <entry key="FUNCTION_23">
         <value>"$2": function name in reserved namespace "$3"</value>
       </entry>
-      
+
       <entry key="ANNOTATION_23">
         <value>"$2": annotation name in reserved namespace "$3"</value>
       </entry>
@@ -937,7 +937,7 @@
       </comment>
       <value>"$1": duplicate decimal format property</value>
     </diagnostic>
-    
+
     <diagnostic code="XQST0116">
       <comment>
       It is a static error if a variable declaration contains both a %private
@@ -962,7 +962,7 @@
       </comment>
       <value>"$1": feature not supported</value>
     </diagnostic>
-    
+
     <diagnostic code="XQST0122">
       <comment>
         It is a static error if the name of a feature in require-feature or
@@ -987,21 +987,21 @@
       </entry>
 
     </diagnostic>
-    
+
     <diagnostic code="XQST0126">
       <comment>
         It is a static error if all-extensions appears in a require-feature option declaration.
       </comment>
       <value>impossible to require all extension features</value>
     </diagnostic>
-    
+
     <diagnostic code="XQST0127">
       <comment>
         It is a static error if a given feature is both required and prohibited, directly or indirectly, in a module.
       </comment>
       <value>$1 : impossible to require and prohibit at the same time</value>
     </diagnostic>
-    
+
     <diagnostic code="XQST0128">
       <comment>
         It is a static error if a feature name that an implementation supports appears
@@ -1010,7 +1010,7 @@
       </comment>
       <value>"$1": unable to disable a supported feature</value>
     </diagnostic>
-    
+
     <diagnostic code="XPDY0002">
       <comment>
        It is a dynamic error if evaluation of an expression relies on some part
@@ -3245,38 +3245,55 @@
       <value>"$1": illegal value for attribute "$2"</value>
     </diagnostic>
 
-    <diagnostic code="ZJSE0004" name="BAD_ELEMENT">
-      <value>"$1": illegal element${; must be "2"}${ or "3"}</value>
-    </diagnostic>
-
-    <diagnostic code="ZJSE0005" name="BAD_CHILD_ELEMENT">
-      <value>"$1": illegal child element of "$2" type; must be "$3"</value>
-    </diagnostic>
-
-    <diagnostic code="ZJSE0006" name="NO_ELEMENT_CHILD">
-      <value>JSON type "$1" can not have a child element node</value>
-    </diagnostic>
-
-    <diagnostic code="ZJSE0007" name="NO_TEXT_CHILD">
-      <value>JSON type "$1" can not have a child text node</value>
-    </diagnostic>
-
-    <diagnostic code="ZJSE0008" name="BAD_VALUE">
+    <diagnostic code="ZJSE0004" name="BAD_NODE">
+      <value>"$1": illegal $2?{child }element/node${ of JSON type "2"}${; must be "3"}</value>
+    </diagnostic>
+
+    <diagnostic code="ZJSE0007" name="ELEMENT_MISSING_VALUE">
+      <value>"$1" element missing required "$2" value</value>
+    </diagnostic>
+
+    <diagnostic code="ZJSE0008" name="BAD_ELEMENT_VALUE">
       <value>"$1": illegal value for JSON type "$2"</value>
     </diagnostic>
-    
+
+    <diagnostic code="ZJSE0009" name="MULTIPLE_CHILDREN">
+      <value>"$1": JSON type "$2" can not have multiple child nodes</value>
+    </diagnostic>
+
+    <!-- /////////// JSON-to-XML errors /////////////////////////////////// -->
+
+    <diagnostic code="ZJ2X0001" name="JSONML_ARRAY_BAD_JSON">
+      <value>JsonML (array form) $1</value>
+      <entry key="ArrayRequired">
+        <value>must start with array</value>
+      </entry>
+      <entry key="EmptyArray">
+        <value>array must not be empty</value>
+      </entry>
+      <entry key="Bad1stElement">
+        <value>array must start with string element</value>
+      </entry>
+      <entry key="BadElement">
+        <value>array must not have a "$2" element</value>
+      </entry>
+      <entry key="UnexpectedObject">
+        <value>allows an object only for the 2nd element</value>
+      </entry>
+    </diagnostic>
+
     <!-- /////////// URI procesing errors ///////////////////////////////// -->
-    
+
     <diagnostic code="ZURI0001" name="OPAQUE_WITH_OTHERS">
       <comment>If the opaque-part section of the URI was specified in conjuction with other non-opaque parts.</comment>
       <value>cannot specify opaque-part in conjunction with host/port/path/user-info/query</value>
     </diagnostic>
-    
+
     <diagnostic code="ZURI0002" name="SCHEME_REQUIRED_FOR_OPAQUE">
       <comment>If an opaque-part section was specified without a scheme section.</comment>
       <value>scheme required when specifying opaque-part</value>
     </diagnostic>
-    
+
     <diagnostic code="ZURI0003" name="SLASH_NEEDED_FOR_ABSOLUTE_URI">
       <comment>If an absolute URI is specified with a path that does not start with slash ("/").</comment>
       <value>path component of absolute URI must begin with /</value>
@@ -3547,7 +3564,7 @@
     <diagnostic code="ZWST0008" name="DEPRECATED">
       <value>"$1": has been deprecated; use "$2" instead</value>
     </diagnostic>
-        
+
     <diagnostic code="ZWST0009" name="COMMON_LANGUAGE_WARNING">
       <comment>
         This warning is enabled when the "common-language" option is employed. It will raise warnings

=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
--- src/diagnostics/pregenerated/diagnostic_list.cpp	2013-06-25 00:41:44 +0000
+++ src/diagnostics/pregenerated/diagnostic_list.cpp	2013-07-26 23:55:36 +0000
@@ -1289,19 +1289,19 @@
 ZorbaErrorCode ZJSE0003_BAD_ATTRIBUTE_VALUE( "ZJSE0003" );
 
 
-ZorbaErrorCode ZJSE0004_BAD_ELEMENT( "ZJSE0004" );
-
-
-ZorbaErrorCode ZJSE0005_BAD_CHILD_ELEMENT( "ZJSE0005" );
-
-
-ZorbaErrorCode ZJSE0006_NO_ELEMENT_CHILD( "ZJSE0006" );
-
-
-ZorbaErrorCode ZJSE0007_NO_TEXT_CHILD( "ZJSE0007" );
-
-
-ZorbaErrorCode ZJSE0008_BAD_VALUE( "ZJSE0008" );
+ZorbaErrorCode ZJSE0004_BAD_NODE( "ZJSE0004" );
+
+
+ZorbaErrorCode ZJSE0007_ELEMENT_MISSING_VALUE( "ZJSE0007" );
+
+
+ZorbaErrorCode ZJSE0008_BAD_ELEMENT_VALUE( "ZJSE0008" );
+
+
+ZorbaErrorCode ZJSE0009_MULTIPLE_CHILDREN( "ZJSE0009" );
+
+
+ZorbaErrorCode ZJ2X0001_JSONML_ARRAY_BAD_JSON( "ZJ2X0001" );
 
 
 ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS( "ZURI0001" );

=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp	2013-06-25 00:41:44 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp	2013-07-26 23:55:36 +0000
@@ -394,6 +394,7 @@
 #if defined(ZORBA_WITH_DEBUGGER)
   { "ZGDB0001", "" },
 #endif
+  { "ZJ2X0001", "JsonML (array form) $1" },
   { "ZJPE0001", "'$1': illegal JSON character" },
   { "ZJPE0002", "\"$1\": illegal Unicode code-point" },
   { "ZJPE0003", "'\\\\$1': illegal JSON character escape" },
@@ -407,11 +408,10 @@
   { "ZJSE0001", "JSON serialization requires document or element node" },
   { "ZJSE0002", "\"$1\" element missing required \"$2\" attribute" },
   { "ZJSE0003", "\"$1\": illegal value for attribute \"$2\"" },
-  { "ZJSE0004", "\"$1\": illegal element${; must be \"2\"}${ or \"3\"}" },
-  { "ZJSE0005", "\"$1\": illegal child element of \"$2\" type; must be \"$3\"" },
-  { "ZJSE0006", "JSON type \"$1\" can not have a child element node" },
-  { "ZJSE0007", "JSON type \"$1\" can not have a child text node" },
+  { "ZJSE0004", "\"$1\": illegal $2?{child }element/node${ of JSON type \"2\"}${; must be \"3\"}" },
+  { "ZJSE0007", "\"$1\" element missing required \"$2\" value" },
   { "ZJSE0008", "\"$1\": illegal value for JSON type \"$2\"" },
+  { "ZJSE0009", "\"$1\": JSON type \"$2\" can not have multiple child nodes" },
   { "ZOSE0001", "\"$1\": file not found" },
   { "ZOSE0002", "\"$1\": not plain file" },
   { "ZOSE0003", "stream read failure" },
@@ -974,6 +974,11 @@
   { "~ZDST0027_NO_KEY_TYPE_DECL", "value index missing key type declaration" },
   { "~ZDST0060_unknown_localname", "unknown localname ($3)" },
   { "~ZDST0060_unknown_namespace", "unknown namespace ($3)" },
+  { "~ZJ2X0001_ArrayRequired", "must start with array" },
+  { "~ZJ2X0001_Bad1stElement", "array must start with string element" },
+  { "~ZJ2X0001_BadElement", "array must not have a \"$2\" element" },
+  { "~ZJ2X0001_EmptyArray", "array must not be empty" },
+  { "~ZJ2X0001_UnexpectedObject", "allows an object only for the 2nd element" },
   { "~ZSTR0060_ForCollection_3", "for collection \"$3\"" },
   { "~ZSTR0060_ForSequence", "for sequence" },
   { "~ZWST0005_PARAM_TYPE", "type of parameter $3 is $4 which is not a subtype of xs:anyAtomicType" },

=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h	2013-06-25 00:41:44 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h	2013-07-26 23:55:36 +0000
@@ -168,6 +168,11 @@
 #define ZED_ZDST0060_unknown_localname "~ZDST0060_unknown_localname"
 #define ZED_ZSTR0060_ForCollection_3 "~ZSTR0060_ForCollection_3"
 #define ZED_ZSTR0060_ForSequence "~ZSTR0060_ForSequence"
+#define ZED_ZJ2X0001_ArrayRequired "~ZJ2X0001_ArrayRequired"
+#define ZED_ZJ2X0001_EmptyArray "~ZJ2X0001_EmptyArray"
+#define ZED_ZJ2X0001_Bad1stElement "~ZJ2X0001_Bad1stElement"
+#define ZED_ZJ2X0001_BadElement "~ZJ2X0001_BadElement"
+#define ZED_ZJ2X0001_UnexpectedObject "~ZJ2X0001_UnexpectedObject"
 #define ZED_JNUP0007_Object "~JNUP0007_Object"
 #define ZED_JNUP0007_Array "~JNUP0007_Array"
 #define ZED_JNUP0007_ObjectArray "~JNUP0007_ObjectArray"

=== modified file 'src/functions/pregenerated/func_json.cpp'
--- src/functions/pregenerated/func_json.cpp	2013-07-11 00:46:02 +0000
+++ src/functions/pregenerated/func_json.cpp	2013-07-26 23:55:36 +0000
@@ -58,9 +58,9 @@
       {
     DECL_WITH_KIND(sctx, fn_zorba_json_json_to_xml_internal,
         (createQName("http://zorba.io/modules/json-xml","","json-to-xml-internal";), 
-        GENV_TYPESYSTEM.STRING_TYPE_ONE, 
-        GENV_TYPESYSTEM.ITEM_TYPE_QUESTION, 
-        GENV_TYPESYSTEM.ELEMENT_TYPE_STAR),
+        GENV_TYPESYSTEM.JSON_ITEM_TYPE_QUESTION, 
+        GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE, 
+        GENV_TYPESYSTEM.ELEMENT_TYPE_QUESTION),
         FunctionConsts::FN_ZORBA_JSON_JSON_TO_XML_INTERNAL_2);
 
   }
@@ -72,8 +72,8 @@
     DECL_WITH_KIND(sctx, fn_zorba_json_xml_to_json_internal,
         (createQName("http://zorba.io/modules/json-xml","","xml-to-json-internal";), 
         GENV_TYPESYSTEM.ITEM_TYPE_STAR, 
-        GENV_TYPESYSTEM.ITEM_TYPE_QUESTION, 
-        GENV_TYPESYSTEM.STRING_TYPE_ONE),
+        GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE, 
+        GENV_TYPESYSTEM.JSON_ITEM_TYPE_STAR),
         FunctionConsts::FN_ZORBA_JSON_XML_TO_JSON_INTERNAL_2);
 
   }

=== modified file 'src/runtime/json/common.cpp'
--- src/runtime/json/common.cpp	2013-02-12 23:10:13 +0000
+++ src/runtime/json/common.cpp	2013-07-26 23:55:36 +0000
@@ -34,7 +34,7 @@
   i->open();
   store::Item_t att_item;
   while ( i->next( att_item ) ) {
-    if ( att_item->getNodeName()->getStringValue() == att_name ) {
+    if ( name_of( att_item ) == att_name ) {
       att_item->getStringValue2( *att_value );
       found = true;
       break;

=== modified file 'src/runtime/json/common.h'
--- src/runtime/json/common.h	2013-02-26 04:12:43 +0000
+++ src/runtime/json/common.h	2013-07-26 23:55:36 +0000
@@ -17,12 +17,15 @@
 #ifndef ZORBA_RUNTIME_JSON_COMMON_H
 #define ZORBA_RUNTIME_JSON_COMMON_H
 
+// standard
 #include <iostream>
 #include <stack>
 
+// Zorba
 #include "diagnostics/xquery_exception.h"
 #include "store/api/item.h"
 #include "store/api/item_factory.h"
+#include "store/api/iterator.h"
 #include "util/indent.h"
 #include "util/json_parser.h"
 #include "util/omanip.h"
@@ -34,14 +37,14 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-typedef std::stack<store::Item*> item_stack_type;
-
 enum parse_state {
   in_array,
   in_object
 };
 
-typedef std::stack<int> state_stack_type;
+typedef std::stack<store::Item*> item_stack_type;
+typedef std::stack<store::Iterator*> iterator_stack_type;
+typedef std::stack<parse_state> state_stack_type;
 
 namespace whitespace {
   enum type {
@@ -58,6 +61,10 @@
 bool get_attribute_value( store::Item_t const &element, char const *att_name,
                           zstring *att_value );
 
+inline zstring name_of( store::Item_t const &node ) {
+  return node->getNodeName()->getStringValue();
+}
+
 inline void set_data( XQueryException *xe, json::exception const &je ) {
   set_data( *xe, je.get_loc() );
 }
@@ -70,16 +77,28 @@
 
 std::ostream& operator<<( std::ostream &o, parse_state s );
 
-# define PUSH_ITEM(I)                                                     \
-    do {                                                                  \
-      cout << __LINE__ << ":PUSH_ITEM( " << (I)->show() << " )" << endl;  \
-      item_stack.push( (I).getp() );                                      \
-    } while (0)
-
-# define POP_ITEM()                               \
-    do {                                          \
-      cout << __LINE__ << ":POP_ITEM()" << endl;  \
-      cur_item = ztd::pop_stack( item_stack );    \
+# define PUSH_ITEM(I)                           \
+    do {                                        \
+      cout << __LINE__ << ":PUSH_ITEM( " #I ", " << (I##_item)->show() << " )" << endl; \
+      I##_item_stack.push( (I##_item).getp() ); \
+    } while (0)
+
+# define POP_ITEM(I)                                      \
+    do {                                                  \
+      cout << __LINE__ << ":POP_ITEM( " #I " )" << endl;  \
+      I##_item = ztd::pop_stack( I##_item_stack );        \
+    } while (0)
+
+# define PUSH_ITERATOR(I)                             \
+    do {                                              \
+      cout << __LINE__ << ":PUSH_ITERATOR()" << endl; \
+      iterator_stack.push( (I).release() );              \
+    } while (0)
+
+# define POP_ITERATOR(I)                              \
+    do {                                              \
+      cout << __LINE__ << ":POP_ITERATOR()" << endl;  \
+      cur_iter = ztd::pop_stack( iterator_stack );    \
     } while (0)
 
 # define PUSH_STATE(S) \
@@ -88,18 +107,24 @@
       state_stack.push( S );                                      \
     } while (0)
 
-# define POP_STATE()                              \
-    do {                                          \
-      cout << __LINE__ << ":POP_STATE()" << endl; \
-      state_stack.pop();                          \
-    } while (0)                                   \
+# define POP_STATE()                                                  \
+    do {                                                              \
+      cout << __LINE__ << ":POP_STATE()" << endl;                     \
+      state_stack.pop();                                              \
+      if ( state_stack.empty() )                                      \
+        cout << "(state stack is empty)" << endl;                     \
+      else                                                            \
+        cout << "(state is now " << state_stack.top() << ')' << endl; \
+    } while (0)                                                       \
 
 #else
 
-# define PUSH_ITEM(I)   item_stack.push( (I).getp() )
-# define POP_ITEM()     cur_item = ztd::pop_stack( item_stack )
-# define PUSH_STATE(S)  state_stack.push( S )
-# define POP_STATE()    state_stack.pop()
+# define PUSH_ITEM(I)       I##_item_stack.push( (I##_item).getp() )
+# define POP_ITEM(I)        I##_item = ztd::pop_stack( I##_item_stack )
+# define PUSH_ITERATOR(I)   iterator_stack.push( (I).release() )
+# define POP_ITERATOR()     cur_iter = ztd::pop_stack( iterator_stack )
+# define PUSH_STATE(S)      state_stack.push( S )
+# define POP_STATE()        state_stack.pop()
 
 #endif /* ZORBA_DEBUG_JSON */
 

=== modified file 'src/runtime/json/json_impl.cpp'
--- src/runtime/json/json_impl.cpp	2013-07-11 00:46:02 +0000
+++ src/runtime/json/json_impl.cpp	2013-07-26 23:55:36 +0000
@@ -42,12 +42,13 @@
 static void get_options( store::Item_t const &options_object,
                          options_type *options ) {
   ZORBA_ASSERT( options_object->getKind() == store::Item::OBJECT );
-  store::Iterator_t i = options_object->getObjectKeys();
+  store::Iterator_t i( options_object->getObjectKeys() );
   i->open();
-  store::Item_t option_key;
-  while ( i->next( option_key ) ) {
-    zstring const name( option_key->getStringValue() );
-    (*options)[ name ] = options_object->getObjectValue(option_key)->getStringValue();
+  store::Item_t opt_key;
+  while ( i->next( opt_key ) ) {
+    zstring const opt_name( opt_key->getStringValue() );
+    store::Item_t const opt_value( options_object->getObjectValue( opt_key ) );
+    (*options)[ opt_name ] = opt_value->getStringValue();
   }
   i->close();
 }
@@ -56,128 +57,29 @@
 
 bool JSONtoXMLInternal::nextImpl( store::Item_t& result,
                                   PlanState &planState ) const {
-  store::Item_t cur_item;
+  store::Item_t item;
   options_type options;
-  istringstream iss;
-  mem_streambuf buf;
-  zstring s;
-  char const *stream_uri;
 
   PlanIteratorState *state;
   DEFAULT_STACK_INIT( PlanIteratorState, state, planState );
 
   ZORBA_ASSERT( theChildren.size() == 2 );
-  consumeNext( cur_item, theChildren[1], planState );
-  get_options( cur_item, &options );
+  consumeNext( item, theChildren[1], planState );
+  get_options( item, &options );
 
-  consumeNext( cur_item, theChildren[0], planState );
+  consumeNext( item, theChildren[0], planState );
   result = nullptr;
 
-  istream *is;
-  if ( cur_item->isStreamable() ) {
-    is = &cur_item->getStream();
-    stream_uri = get_uri( *is );
-  } else {
-    cur_item->getStringValue2( s );
-    // Doing it this way uses the string data in-place with no copy.
-    buf.set( s.data(), s.size() );
-    iss.ios::rdbuf( &buf );
-    is = &iss;
-    stream_uri = nullptr;
-  }
-
-  try {
-    json::parser p( *is );
-    if ( stream_uri )
-      p.set_loc( stream_uri, 1, 1 );
-    else
-      p.set_loc(
-        loc.getFilename().c_str(), loc.getLineBegin(), loc.getColumnBegin()
-      );
-
-    options_type::mapped_type const &format = options[ "json-format" ];
-    ZORBA_ASSERT( !format.empty() );
-    if ( format == "Snelson" )
-      snelson::parse( p, &result );
-    else if ( format == "JsonML-array" )
-      jsonml_array::parse( p, &result );
-    else
-      ZORBA_ASSERT( false );
-  }
-  catch ( json::illegal_character const &e ) {
-    XQueryException xe(
-      XQUERY_EXCEPTION(
-        zerr::ZJPE0001_ILLEGAL_CHARACTER,
-        ERROR_PARAMS( ascii::printable_char( e.get_char() ) ),
-        ERROR_LOC( e.get_loc() )
-      )
-    );
-    set_data( &xe, e );
-    throw xe;
-  }
-  catch ( json::illegal_codepoint const &e ) {
-    XQueryException xe(
-      XQUERY_EXCEPTION(
-        zerr::ZJPE0002_ILLEGAL_CODEPOINT,
-        ERROR_PARAMS( e.get_codepoint() ),
-        ERROR_LOC( e.get_loc() )
-      )
-    );
-    set_data( &xe, e );
-    throw xe;
-  }
-  catch ( json::illegal_escape const &e ) {
-    XQueryException xe(
-      XQUERY_EXCEPTION(
-        zerr::ZJPE0003_ILLEGAL_ESCAPE,
-        ERROR_PARAMS( e.get_escape() ),
-        ERROR_LOC( e.get_loc() )
-      )
-    );
-    set_data( &xe, e );
-    throw xe;
-  }
-  catch ( json::illegal_literal const &e ) {
-    XQueryException xe(
-      XQUERY_EXCEPTION(
-        zerr::ZJPE0004_ILLEGAL_LITERAL,
-        ERROR_LOC( e.get_loc() )
-      )
-    );
-    set_data( &xe, e );
-    throw xe;
-  }
-  catch ( json::illegal_number const &e ) {
-    XQueryException xe(
-      XQUERY_EXCEPTION(
-        zerr::ZJPE0005_ILLEGAL_NUMBER,
-        ERROR_LOC( e.get_loc() )
-      )
-    );
-    set_data( &xe, e );
-    throw xe;
-  }
-  catch ( json::unexpected_token const &e ) {
-    XQueryException xe(
-      XQUERY_EXCEPTION(
-        zerr::ZJPE0006_UNEXPECTED_TOKEN,
-        ERROR_PARAMS( e.get_token() ),
-        ERROR_LOC( e.get_loc() )
-      )
-    );
-    set_data( &xe, e );
-    throw xe;
-  }
-  catch ( json::unterminated_string const &e ) {
-    XQueryException xe(
-      XQUERY_EXCEPTION(
-        zerr::ZJPE0007_UNTERMINATED_STRING,
-        ERROR_LOC( e.get_loc() )
-      )
-    );
-    set_data( &xe, e );
-    throw xe;
-  }
+  { // local scope
+  options_type::mapped_type const &format = options[ "json-format" ];
+  ZORBA_ASSERT( !format.empty() );
+  if ( format == "Snelson" )
+    snelson::json_to_xml( item, &result );
+  else if ( format == "JsonML-array" )
+    jsonml_array::json_to_xml( item, &result );
+  else
+    ZORBA_ASSERT( false );
+  } // local scope
 
   STACK_PUSH( !!result, state );
   STACK_END( state );
@@ -186,41 +88,29 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 bool XMLtoJSONInternal::nextImpl( store::Item_t& result,
-                                      PlanState &planState ) const {
-  store::Item_t cur_item;
+                                  PlanState &planState ) const {
+  store::Item_t xml_item;
   options_type options;
 
   PlanIteratorState *state;
   DEFAULT_STACK_INIT( PlanIteratorState, state, planState );
 
   ZORBA_ASSERT( theChildren.size() == 2 );
-  consumeNext( cur_item, theChildren[1], planState );
-  get_options( cur_item, &options );
+  consumeNext( xml_item, theChildren[1], planState );
+  get_options( xml_item, &options );
 
-  consumeNext( cur_item, theChildren[0], planState );
+  consumeNext( xml_item, theChildren[0], planState );
   try {
     options_type::mapped_type const &format_opt = options[ "json-format" ];
     ZORBA_ASSERT( !format_opt.empty() );
 
-    whitespace::type ws;
-    options_type::mapped_type const &whitespace_opt = options[ "whitespace" ];
-    if ( whitespace_opt.empty() || whitespace_opt == "none" )
-      ws = whitespace::none;
-    else if ( whitespace_opt == "some" )
-      ws = whitespace::some;
-    else if ( whitespace_opt == "indent" )
-      ws = whitespace::indent;
-    else
-      ZORBA_ASSERT( false );
-
-    ostringstream oss;
-    switch ( cur_item->getNodeKind() ) {
+    switch ( xml_item->getNodeKind() ) {
       case store::StoreConsts::documentNode:
       case store::StoreConsts::elementNode:
         if ( format_opt == "Snelson" )
-          snelson::serialize( oss, cur_item, ws );
+          snelson::xml_to_json( xml_item, &result );
         else if ( format_opt == "JsonML-array" )
-          jsonml_array::serialize( oss, cur_item, ws );
+          jsonml_array::xml_to_json( xml_item, &result );
         else
           ZORBA_ASSERT( false );
         break;
@@ -230,9 +120,6 @@
           ERROR_LOC( loc )
         );
     }
-    // This string copying is inefficient, but I can't see another way.
-    zstring temp( oss.str() );
-    GENV_ITEMFACTORY->createString( result, temp );
   }
   catch ( ZorbaException &e ) {
     set_source( e, loc );

=== modified file 'src/runtime/json/jsonml_array.cpp'
--- src/runtime/json/jsonml_array.cpp	2013-06-18 02:28:10 +0000
+++ src/runtime/json/jsonml_array.cpp	2013-07-26 23:55:36 +0000
@@ -24,44 +24,10 @@
 #include "store/api/item_factory.h"
 #include "system/globalenv.h"
 #include "types/root_typemanager.h"
-#include "util/ascii_util.h"
-#include "util/json_parser.h"
-#include "util/json_util.h"
-#include "util/mem_streambuf.h"
-#include "util/omanip.h"
-#include "util/oseparator.h"
 #include "util/stl_util.h"
-#include "util/xml_util.h"
 
 #include "jsonml_array.h"
 
-using namespace std;
-
-namespace zorba {
-
-///////////////////////////////////////////////////////////////////////////////
-
-inline void split_name( zstring const &name, zstring *prefix, zstring *local ) {
-  if ( !xml::split_qname( name, prefix, local ) )
-    throw XQUERY_EXCEPTION(
-      zerr::ZJPE0008_ILLEGAL_QNAME,
-      ERROR_PARAMS( name )
-    );
-}
-
-namespace expect {
-  enum type {
-    none,
-    element_name,
-    attribute_name,
-    attribute_value
-  };
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-namespace jsonml_array {
-
 // JsonML grammar
 // Source: http://www.ibm.com/developerworks/library/x-jsonml/#N10138
 //
@@ -97,232 +63,266 @@
 //     | element
 //     ;
 
-void parse( json::parser &p, store::Item_t *result ) {
-  ZORBA_ASSERT( result );
-
-  state_stack_type state_stack;
-
-  store::Item_t cur_item, junk_item, value_item;
-  store::Item_t att_name, element_name, type_name;
-
+using namespace std;
+
+namespace zorba {
+namespace jsonml_array {
+
+///////////////////////////////////////////////////////////////////////////////
+
+static void j2x_object( store::Item_t const &object_item,
+                        store::Item_t *parent_xml_item ) {
+  ZORBA_ASSERT( parent_xml_item );
+  store::Iterator_t k( object_item->getObjectKeys() );
+  k->open();
+  store::Item_t junk_item, key_item, type_name;
+  while ( k->next( key_item ) ) {
+    store::Item_t att_name;
+    GENV_ITEMFACTORY->createQName(
+      att_name, "", "", key_item->getStringValue()
+    );
+    store::Item_t value_item( object_item->getObjectValue( key_item ) );
+    zstring value_str( value_item->getStringValue() );
+    GENV_ITEMFACTORY->createString( value_item, value_str );
+    type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+    GENV_ITEMFACTORY->createAttributeNode(
+      junk_item, *parent_xml_item, att_name, type_name, value_item
+    );
+  }
+  k->close();
+}
+
+static store::Item_t j2x_array( store::Item_t const &array_item,
+                                store::Item *parent_xml_item ) {
   zstring base_uri;
-  bool got_something = false;
-  item_stack_type item_stack;
-  expect::type expect_what = expect::none;
   store::NsBindings ns_bindings;
-  zstring value;
-
-  json::token token;
-  while ( p.next( &token ) ) {
-    got_something = true;
-    switch ( token.get_type() ) {
-
-      case '[':
-        if ( expect_what )
-          throw XQUERY_EXCEPTION(
-            zerr::ZJPE0006_UNEXPECTED_TOKEN,
-            ERROR_PARAMS( token )
-          );
-        PUSH_STATE( in_array );
-        expect_what = expect::element_name;
-        break;
-
-      case '{':
-        if ( expect_what )
-          throw XQUERY_EXCEPTION(
-            zerr::ZJPE0006_UNEXPECTED_TOKEN,
-            ERROR_PARAMS( token )
-          );
-        if ( state_stack.empty() )
-          throw XQUERY_EXCEPTION(
-            zerr::ZJPE0010_JSONML_ARRAY_REQUIRES_BRACKET
-          );
-        PUSH_STATE( in_object );
-        expect_what = expect::attribute_name;
-        break;
-
-      case ']':
-        POP_ITEM();
-        // no break;
-      case '}':
-        POP_STATE();
-        expect_what = expect::none;
-        break;
-
-      case ',':
-        expect_what = IN_STATE( in_object ) ?
-          expect::attribute_name : expect::none;
-        break;
-
-      case ':':
-        expect_what = expect::attribute_value;
-        break;
-
-      case json::token::number:
-      case 'F':
-      case 'T':
-      case json::token::json_null:
-      case json::token::string: {
-        value = token.get_value();
-        zstring prefix, local;
-        switch ( expect_what ) {
-          case expect::element_name:
-            split_name( value, &prefix, &local );
-            GENV_ITEMFACTORY->createQName( element_name, "", prefix, local );
-            type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
-            GENV_ITEMFACTORY->createElementNode(
-              cur_item,
-              item_stack.empty() ? nullptr : item_stack.top(),
-              element_name, type_name, false, false, ns_bindings, base_uri
-            );
-            PUSH_ITEM( cur_item );
-            if ( !*result )
-              *result = cur_item;
-            break;
-          case expect::attribute_name:
-            split_name( value, &prefix, &local );
-            GENV_ITEMFACTORY->createQName( att_name, "", prefix, local );
-            break;
-          case expect::attribute_value:
-            type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
-            GENV_ITEMFACTORY->createString( value_item, value );
-            GENV_ITEMFACTORY->createAttributeNode(
-              junk_item, cur_item, att_name, type_name, value_item
-            );
-            break;
-          case expect::none:
-            GENV_ITEMFACTORY->createTextNode( junk_item, cur_item, value );
-            break;
-        }
+  store::Item_t array_elt_item, element_name, junk_item, type_name, xml_item;
+
+  store::Iterator_t i( array_item->getArrayValues() );
+  i->open();
+
+  if ( !i->next( array_elt_item ) )
+    throw XQUERY_EXCEPTION(
+      zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON,
+      ERROR_PARAMS( ZED( ZJ2X0001_EmptyArray ) )
+    );
+  if ( !array_elt_item->isAtomic() )
+    throw XQUERY_EXCEPTION(
+      zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON,
+      ERROR_PARAMS( ZED( ZJ2X0001_Bad1stElement ) )
+    );
+
+  switch ( array_elt_item->getTypeCode() ) {
+    case store::XS_ENTITY:
+    case store::XS_ID:
+    case store::XS_IDREF:
+    case store::XS_NAME:
+    case store::XS_NCNAME:
+    case store::XS_NMTOKEN:
+    case store::XS_NORMALIZED_STRING:
+    case store::XS_STRING:
+    case store::XS_TOKEN:
+      break;
+    default:
+      throw XQUERY_EXCEPTION(
+        zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON,
+        ERROR_PARAMS( ZED( ZJ2X0001_Bad1stElement ) )
+      );
+  } // switch
+
+  GENV_ITEMFACTORY->createQName(
+    element_name, "", "", array_elt_item->getStringValue()
+  );
+  type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+  GENV_ITEMFACTORY->createElementNode(
+    xml_item, parent_xml_item,
+    element_name, type_name, false, false, ns_bindings, base_uri
+  );
+
+  bool did_attributes = false;
+  while ( i->next( array_elt_item ) ) {
+    switch ( array_elt_item->getKind() ) {
+      case store::Item::ARRAY:
+        j2x_array( array_elt_item, xml_item.getp() );
+        break;
+      case store::Item::ATOMIC: {
+        zstring value_str( array_elt_item->getStringValue() );
+        GENV_ITEMFACTORY->createTextNode( junk_item, xml_item, value_str );
         break;
       }
-
-      case json::token::none:
+      case store::Item::OBJECT:
+        if ( did_attributes )
+          throw XQUERY_EXCEPTION(
+            zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON,
+            ERROR_PARAMS( ZED( ZJ2X0001_UnexpectedObject ) )
+          );
+        j2x_object( array_elt_item, &xml_item );
+        did_attributes = true;
         break;
-
       default:
-        assert( false );
+        throw XQUERY_EXCEPTION(
+          zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON,
+          ERROR_PARAMS( ZED( ZJ2X0001_BadElement ), array_elt_item->getKind() )
+        );
     } // switch
   } // while
-  if ( !got_something )
-    throw XQUERY_EXCEPTION( zerr::ZJPE0009_ILLEGAL_EMPTY_STRING );
-}
-
-} // namespace jsonml_array
+
+  i->close();
+  return xml_item;
+}
+
+void json_to_xml( store::Item_t const &json_item, store::Item_t *xml_item ) {
+  ZORBA_ASSERT( xml_item );
+  switch ( json_item->getKind() ) {
+    case store::Item::ARRAY:
+      *xml_item = j2x_array( json_item, nullptr );
+      break;
+    case store::Item::OBJECT:
+      throw XQUERY_EXCEPTION(
+        zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON,
+        ERROR_PARAMS( ZED( ZJ2X0001_ArrayRequired ) )
+      );
+    default:
+      ZORBA_ASSERT( false );
+  }
+}
 
 ///////////////////////////////////////////////////////////////////////////////
 
-static ostream& serialize_attributes( ostream &o, store::Item_t const &element,
-                                      oseparator &sep, whitespace::type ws ) {
-  bool emitted_attributes = false;
-  oseparator att_sep;
-  switch ( ws ) {
-    case whitespace::none  : att_sep.sep( ","   ); break;
-    case whitespace::some  : att_sep.sep( ", "  ); break;
-    case whitespace::indent: att_sep.sep( ",\n" ); break;
-  }
+static bool x2j_map_atomic_item( store::Item_t const &xml_item,
+                                 store::Item_t *json_item ) {
+  if ( xml_item->isAtomic() ) {
+    switch ( xml_item->getTypeCode() ) {
+      case store::JS_NULL:
+      case store::XS_BOOLEAN:
+      case store::XS_BYTE:
+      case store::XS_DECIMAL:
+      case store::XS_DOUBLE:
+      case store::XS_ENTITY:
+      case store::XS_FLOAT:
+      case store::XS_ID:
+      case store::XS_IDREF:
+      case store::XS_INT:
+      case store::XS_INTEGER:
+      case store::XS_LONG:
+      case store::XS_NAME:
+      case store::XS_NCNAME:
+      case store::XS_NEGATIVE_INTEGER:
+      case store::XS_NMTOKEN:
+      case store::XS_NON_NEGATIVE_INTEGER:
+      case store::XS_NON_POSITIVE_INTEGER:
+      case store::XS_NORMALIZED_STRING:
+      case store::XS_POSITIVE_INTEGER:
+      case store::XS_SHORT:
+      case store::XS_STRING:
+      case store::XS_TOKEN:
+      case store::XS_UNSIGNED_BYTE:
+      case store::XS_UNSIGNED_INT:
+      case store::XS_UNSIGNED_LONG:
+      case store::XS_UNSIGNED_SHORT:
+        *json_item = xml_item;
+        break;
+      default:
+        zstring s( xml_item->getStringValue() );
+        GENV_ITEMFACTORY->createString( *json_item, s );
+        break;
+    } // switch
+    return true;
+  } // if
+  return false;
+}
+
+static void x2j_attributes( store::Item_t const &element,
+                            store::Item_t *json_item ) {
+  ZORBA_ASSERT( json_item );
+
+  store::Item_t att_item, item;
+  vector<store::Item_t> keys, values;
 
   store::Iterator_t i( element->getAttributes() );
   i->open();
-  store::Item_t att_item;
   while ( i->next( att_item ) ) {
-    zstring const att_name( att_item->getNodeName()->getStringValue() );
+    zstring att_name( name_of( att_item ) );
     if ( att_name == "xmlns" )
       continue;
-    if ( !emitted_attributes ) {
-      o << sep
-        << if_emit( ws == whitespace::indent, '\n' )
-        << if_indent( ws, indent ) << '{'
-        << if_indent( ws, inc_indent );
-      emitted_attributes = true;
-    }
-    bool const was_printing = att_sep.printing();
-    o << att_sep;
-    if ( was_printing )
-      o << if_indent( ws, indent );
-    else
-      o << if_emit( ws, ' ' );
-    
-    o << '"' << att_name << '"'
-      << if_emit( ws, ' ' ) << ':' << if_emit( ws, ' ' )
-      << '"' << json::serialize( att_item->getStringValue() ) << '"';
-  }
+    GENV_ITEMFACTORY->createString( item, att_name );
+    keys.push_back( item );
+    zstring att_value( att_item->getStringValue() );
+    GENV_ITEMFACTORY->createString( item, att_value );
+    values.push_back( item );
+  } // while
   i->close();
-  if ( emitted_attributes )
-    o << if_emit( ws, ' ' ) << '}' << if_indent( ws, dec_indent );
-  return o;
-}
-DEF_OMANIP3( serialize_attributes, store::Item_t const&, oseparator&,
-             whitespace::type )
-
-static ostream& serialize_children( ostream&, store::Item_t const &parent,
-                                    oseparator&, whitespace::type );
-DEF_OMANIP3( serialize_children, store::Item_t const&, oseparator&,
-             whitespace::type )
-
-static ostream& serialize_element( ostream &o, store::Item_t const &element,
-                                   oseparator &sep, whitespace::type ws ) {
-  if ( sep.printing() )
-    o << if_emit( ws == whitespace::indent, '\n' );
-  sep.printing( true );
-  o << if_indent( ws, indent ) << '[' << if_emit( ws, ' ' )
-    << '"' << element->getNodeName()->getStringValue() << '"'
-    << if_indent( ws, inc_indent )
-    << serialize_attributes( element, sep, ws )
-    << serialize_children( element, sep, ws )
-    << if_emit( ws, ' ' ) << ']'
-    << if_indent( ws, dec_indent );
-  return o;
-}
-DEF_OMANIP3( serialize_element, store::Item_t const&, oseparator&,
-             whitespace::type )
-
-static ostream& serialize_children( ostream &o, store::Item_t const &parent,
-                                    oseparator &sep, whitespace::type ws ) {
+  if ( !keys.empty() )
+    GENV_ITEMFACTORY->createJSONObject( *json_item, keys, values );
+}
+
+// forward declaration
+static void x2j_element( store::Item_t const &element,
+                         store::Item_t *json_item );
+
+static void x2j_children( store::Item_t const &parent,
+                          vector<store::Item_t> *elements ) {
+  ZORBA_ASSERT( elements );
   store::Iterator_t i( parent->getChildren() );
   i->open();
-  store::Item_t child;
-  while ( i->next( child ) ) {
-    switch ( child->getNodeKind() ) {
-      case store::StoreConsts::elementNode:
-        o << sep << serialize_element( child, sep, ws );
-        break;
-      case store::StoreConsts::textNode:
-        o << sep << '"' << json::serialize( child->getStringValue() ) << '"';
-        break;
-      default:
-        break;
-    }
-  }
+  store::Item_t child_item, temp_item;
+  while ( i->next( child_item ) ) {
+    if ( !x2j_map_atomic_item( child_item, &temp_item ) ) {
+      if ( !child_item->isNode() )
+        throw XQUERY_EXCEPTION(
+          zerr::ZJ2X0001_JSONML_ARRAY_BAD_JSON,
+          ERROR_PARAMS( ZED( ZJ2X0001_BadElement ), child_item->getKind() )
+        );
+      switch ( child_item->getNodeKind() ) {
+        case store::StoreConsts::elementNode:
+          x2j_element( child_item, &temp_item );
+          break;
+        case store::StoreConsts::textNode: {
+          zstring s( child_item->getStringValue() );
+          GENV_ITEMFACTORY->createString( temp_item, s );
+          break;
+        }
+        default:
+          continue;
+      } // switch
+    } // if
+    elements->push_back( temp_item );
+  } // while
   i->close();
-  return o;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-namespace jsonml_array {
-
-void serialize( ostream &o, store::Item_t const &item, whitespace::type ws ) {
-  oseparator sep;
-  if ( ws )
-    sep.sep( ", " );
-  else
-    sep.sep( "," );
-  switch ( item->getNodeKind() ) {
+}
+
+static void x2j_element( store::Item_t const &element,
+                         store::Item_t *json_item ) {
+  ZORBA_ASSERT( json_item );
+  store::Item_t name_item, attributes_item;
+  vector<store::Item_t> elements;
+
+  zstring name( name_of( element ) );
+  GENV_ITEMFACTORY->createString( name_item, name );
+  elements.push_back( name_item );
+  x2j_attributes( element, &attributes_item );
+  if ( !attributes_item.isNull() )
+    elements.push_back( attributes_item );
+  x2j_children( element, &elements );
+  GENV_ITEMFACTORY->createJSONArray( *json_item, elements );
+}
+
+void xml_to_json( store::Item_t const &xml_item, store::Item_t *json_item ) {
+  ZORBA_ASSERT( json_item );
+  switch ( xml_item->getNodeKind() ) {
     case store::StoreConsts::documentNode:
-      o << serialize_children( item, sep, ws );
+      //x2j_children( xml_item, json_item );
       break;
     case store::StoreConsts::elementNode:
-      o << serialize_element( item, sep, ws );
+      x2j_element( xml_item, json_item );
       break;
     default:
       throw XQUERY_EXCEPTION( zerr::ZJSE0001_NOT_DOCUMENT_OR_ELEMENT_NODE );
   }
 }
 
+///////////////////////////////////////////////////////////////////////////////
+
 } // namespace jsonml_array
-
-///////////////////////////////////////////////////////////////////////////////
-
 } // namespace zorba
 /* vim:set et sw=2 ts=2: */

=== modified file 'src/runtime/json/jsonml_array.h'
--- src/runtime/json/jsonml_array.h	2011-12-27 01:15:25 +0000
+++ src/runtime/json/jsonml_array.h	2013-07-26 23:55:36 +0000
@@ -21,7 +21,6 @@
 #include <iostream>
 
 #include "store/api/item.h"
-#include "util/json_parser.h"
 
 #include "common.h"
 
@@ -30,8 +29,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void parse( json::parser &p, store::Item_t *result );
-void serialize( std::ostream&, store::Item_t const &item, whitespace::type );
+void json_to_xml( store::Item_t const &json_item, store::Item_t *xml_item );
+void xml_to_json( store::Item_t const &xml_item, store::Item_t *json_item );
 
 ///////////////////////////////////////////////////////////////////////////////
 

=== modified file 'src/runtime/json/snelson.cpp'
--- src/runtime/json/snelson.cpp	2013-06-01 00:30:39 +0000
+++ src/runtime/json/snelson.cpp	2013-07-26 23:55:36 +0000
@@ -25,14 +25,12 @@
 #include "store/api/item_factory.h"
 #include "system/globalenv.h"
 #include "types/root_typemanager.h"
-#include "util/ascii_util.h"
-#include "util/indent.h"
 #include "util/json_parser.h"
-#include "util/json_util.h"
 #include "util/mem_streambuf.h"
-#include "util/omanip.h"
-#include "util/oseparator.h"
 #include "util/stl_util.h"
+#include "zorbatypes/decimal.h"
+#include "zorbatypes/float.h"
+#include "zorbatypes/integer.h"
 
 #include "snelson.h"
 
@@ -41,6 +39,7 @@
 using namespace std;
 
 namespace zorba {
+namespace snelson {
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -48,179 +47,257 @@
   store::Item_t junk_item, att_name, type_name, value_item;
   GENV_ITEMFACTORY->createQName( att_name, "", "", "type" );
   type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
-  zstring value_string( value );
-  GENV_ITEMFACTORY->createString( value_item, value_string );
+  zstring value_str( value );
+  GENV_ITEMFACTORY->createString( value_item, value_str );
   GENV_ITEMFACTORY->createAttributeNode(
     junk_item, parent, att_name, type_name, value_item
   );
 }
 
-#define ADD_TYPE_ATTRIBUTE(T)             \
-  do {                                    \
-    if ( needs_type_attribute ) {         \
-      add_type_attribute( cur_item, T );  \
-      needs_type_attribute = false;       \
-    }                                     \
+#define ADD_TYPE_ATTRIBUTE(T)               \
+  do {                                      \
+    if ( needs_type_attribute ) {           \
+      add_type_attribute( xml_item, (T) );  \
+      needs_type_attribute = false;         \
+    }                                       \
   } while (0)
 
-static void add_item_element( item_stack_type &item_stack,
-                              state_stack_type &state_stack,
-                              store::Item_t &cur_item,
+static void add_item_element( item_stack_type &xml_item_stack,
+                              store::Item_t &xml_item,
                               char const *type ) {
-  store::Item_t element_name, type_name;
   zstring base_uri;
+  store::Item_t element_name;
   store::NsBindings ns_bindings;
+
   GENV_ITEMFACTORY->createQName( element_name, SNELSON_NS, "", "item" );
-  type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
-  GENV_ITEMFACTORY->createElementNode(
-    cur_item, item_stack.top(),
-    element_name, type_name, false, false, ns_bindings, base_uri
-  );
-  add_type_attribute( cur_item.getp(), type );
-  PUSH_ITEM( cur_item );
-}
-
-#define ADD_ITEM_ELEMENT(T)                                 \
-  if ( !IN_STATE( in_array ) ) ; else                       \
-  add_item_element( item_stack, state_stack, cur_item, T )
-
-#define POP_ITEM_ELEMENT()  \
-  if ( !IN_STATE( in_array ) ) ; else POP_ITEM()
+  store::Item_t type_name( GENV_TYPESYSTEM.XS_UNTYPED_QNAME );
+  GENV_ITEMFACTORY->createElementNode(
+    xml_item, xml_item_stack.top(),
+    element_name, type_name, false, false, ns_bindings, base_uri
+  );
+  add_type_attribute( xml_item.getp(), type );
+  PUSH_ITEM( xml );
+}
+
+#define ADD_ITEM_ELEMENT(T)                               \
+  do {                                                    \
+    if ( IN_STATE( in_array ) )                           \
+      add_item_element( xml_item_stack, xml_item, (T) );  \
+  } while (0)
+
+#define POP_ITEM_ELEMENT()      \
+  do {                          \
+    if ( IN_STATE( in_array ) ) \
+      POP_ITEM( xml );          \
+  } while (0)
+
+static void add_pair_element( item_stack_type &xml_item_stack,
+                              store::Item_t &xml_item,
+                              zstring const &name ) {
+  zstring base_uri;
+  store::Item_t att_name, element_name, junk_item, name_item, type_name;
+  store::NsBindings ns_bindings;
+
+  GENV_ITEMFACTORY->createQName( element_name, SNELSON_NS, "", "pair" );
+  type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+  GENV_ITEMFACTORY->createElementNode(
+    xml_item, xml_item_stack.top(),
+    element_name, type_name, false, false, ns_bindings, base_uri
+  );
+
+  GENV_ITEMFACTORY->createQName( att_name, "", "", "name" );
+  type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+  zstring name_copy( name );
+  GENV_ITEMFACTORY->createString( name_item, name_copy );
+  GENV_ITEMFACTORY->createAttributeNode(
+    junk_item, xml_item, att_name, type_name, name_item
+  );
+}
+
+#define ADD_PAIR_ELEMENT(NAME)                            \
+  do {                                                    \
+    add_pair_element( xml_item_stack, xml_item, (NAME) ); \
+    needs_type_attribute = true;                          \
+  } while (0)
 
 ///////////////////////////////////////////////////////////////////////////////
 
-namespace snelson {
-
-void parse( json::parser &p, store::Item_t *result ) {
+void json_to_xml( store::Item_t const &item, store::Item_t *result ) {
   ZORBA_ASSERT( result );
 
-  store::Item_t cur_item, junk_item, value_item;
-  store::Item_t att_name, element_name, type_name;
+  store::Item_t element_name, xml_item, junk_item, value_item;
 
   zstring base_uri;
-  bool got_something = false;
-  item_stack_type item_stack;
-  bool needs_type_attribute = false;
-  bool next_string_is_key = false;
+  iterator_stack_type iterator_stack;
+  item_stack_type json_item_stack, xml_item_stack;
   store::NsBindings ns_bindings;
   state_stack_type state_stack;
-  zstring value;
-
-  json::token token;
-  while ( p.next( &token ) ) {
-    got_something = true;
-
-    if ( !*result ) {
-      GENV_ITEMFACTORY->createQName( element_name, SNELSON_NS, "", "json" );
-      type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
-      GENV_ITEMFACTORY->createElementNode(
-        cur_item, nullptr,
-        element_name, type_name, false, false, ns_bindings, base_uri
-      );
-      *result = cur_item;
-      needs_type_attribute = true;
-      PUSH_ITEM( cur_item );
-    }
-
-    switch ( token.get_type() ) {
-
-      case '[':
+
+  GENV_ITEMFACTORY->createQName( element_name, SNELSON_NS, "", "json" );
+  store::Item_t type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
+  GENV_ITEMFACTORY->createElementNode(
+    xml_item, nullptr,
+    element_name, type_name, false, false, ns_bindings, base_uri
+  );
+  bool needs_type_attribute = true;
+  PUSH_ITEM( xml );
+  *result = xml_item;
+
+  store::Item_t json_item( item );
+  PUSH_ITEM( json );
+
+  store::Iterator_t cur_iter;
+  switch ( json_item->getKind() ) {
+    case store::Item::ARRAY:
+      ADD_TYPE_ATTRIBUTE( "array" );
+      cur_iter = json_item->getArrayValues();
+      PUSH_STATE( in_array );
+      break;
+    case store::Item::OBJECT:
+      ADD_TYPE_ATTRIBUTE( "object" );
+      cur_iter = json_item->getObjectKeys();
+      PUSH_STATE( in_object );
+      break;
+    default:
+      ZORBA_ASSERT( false );
+  }
+  cur_iter->open();
+
+  zstring value_str;
+
+  while ( true ) {
+    bool added_pair_element = false;
+    if ( !cur_iter->next( value_item ) ) {
+      cur_iter->close();
+      if ( iterator_stack.empty() )
+        break;
+      POP_ITERATOR();
+      POP_STATE();
+      POP_ITEM_ELEMENT();
+      if ( IN_STATE( in_object ) ) {
+        POP_ITEM( xml );
+        POP_ITEM( json );
+      }
+      continue;
+    }
+    if ( IN_STATE( in_object ) ) {
+      ADD_PAIR_ELEMENT( value_item->getStringValue() );
+      PUSH_ITEM( xml );
+      value_item = json_item->getObjectValue( value_item );
+      added_pair_element = true;
+    }
+
+    switch ( value_item->getKind() ) {
+
+      case store::Item::ATOMIC:
+        switch ( value_item->getTypeCode() ) {
+
+          case store::JS_NULL:
+            ADD_TYPE_ATTRIBUTE( "null" );
+            ADD_ITEM_ELEMENT( "null" );
+            POP_ITEM_ELEMENT();
+            break;
+
+          case store::XS_BOOLEAN:
+            ADD_TYPE_ATTRIBUTE( "boolean" );
+            ADD_ITEM_ELEMENT( "boolean" );
+            value_str = value_item->getBooleanValue() ? "true" : "false";
+            GENV_ITEMFACTORY->createTextNode( junk_item, xml_item, value_str );
+            POP_ITEM_ELEMENT();
+            break;
+
+          case store::XS_BYTE:
+          case store::XS_DECIMAL:
+          case store::XS_DOUBLE:
+          case store::XS_FLOAT:
+          case store::XS_INT:
+          case store::XS_INTEGER:
+          case store::XS_LONG:
+          case store::XS_NEGATIVE_INTEGER:
+          case store::XS_NON_NEGATIVE_INTEGER:
+          case store::XS_NON_POSITIVE_INTEGER:
+          case store::XS_POSITIVE_INTEGER:
+          case store::XS_SHORT:
+          case store::XS_UNSIGNED_BYTE:
+          case store::XS_UNSIGNED_INT:
+          case store::XS_UNSIGNED_LONG:
+          case store::XS_UNSIGNED_SHORT:
+            ADD_TYPE_ATTRIBUTE( "number" );
+            ADD_ITEM_ELEMENT( "number" );
+            value_str = value_item->getStringValue();
+            GENV_ITEMFACTORY->createTextNode( junk_item, xml_item, value_str );
+            POP_ITEM_ELEMENT();
+            break;
+
+          default:
+            ADD_TYPE_ATTRIBUTE( "string" );
+            ADD_ITEM_ELEMENT( "string" );
+            value_str = value_item->getStringValue();
+            GENV_ITEMFACTORY->createTextNode( junk_item, xml_item, value_str );
+            POP_ITEM_ELEMENT();
+        } // switch
+        break;
+
+      case store::Item::ARRAY:
         if ( IN_STATE( in_object ) )
-          PUSH_ITEM( cur_item );
+          PUSH_ITEM( xml );
         ADD_TYPE_ATTRIBUTE( "array" );
         ADD_ITEM_ELEMENT( "array" );
         PUSH_STATE( in_array );
+        PUSH_ITERATOR( cur_iter );
+        cur_iter = value_item->getArrayValues();
+        cur_iter->open();
         break;
 
-      case '{':
+      case store::Item::OBJECT:
         if ( IN_STATE( in_object ) )
-          PUSH_ITEM( cur_item );
+          PUSH_ITEM( xml );
         ADD_TYPE_ATTRIBUTE( "object" );
         ADD_ITEM_ELEMENT( "object" );
         PUSH_STATE( in_object );
-        next_string_is_key = true;
-        break;
-
-      case ']':
-      case '}':
-        POP_STATE();
-        POP_ITEM_ELEMENT();
-        if ( IN_STATE( in_object ) )
-          POP_ITEM();
-        break;
-
-      case ',':
-        next_string_is_key = IN_STATE( in_object );
-        break;
-
-      case json::token::number:
-        ADD_TYPE_ATTRIBUTE( "number" );
-        ADD_ITEM_ELEMENT( "number" );
-        value = token.get_value();
-        GENV_ITEMFACTORY->createTextNode( junk_item, cur_item, value );
-        POP_ITEM_ELEMENT();
-        break;
-
-      case json::token::string:
-        ADD_TYPE_ATTRIBUTE( "string" );
-        value = token.get_value();
-        if ( next_string_is_key ) {
-          // <pair name="..." ...>
-          GENV_ITEMFACTORY->createQName( element_name, SNELSON_NS, "", "pair" );
-          type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
-          GENV_ITEMFACTORY->createElementNode(
-            cur_item, item_stack.top(),
-            element_name, type_name, false, false, ns_bindings, base_uri
-          );
-
-          GENV_ITEMFACTORY->createQName( att_name, "", "", "name" );
-          type_name = GENV_TYPESYSTEM.XS_UNTYPED_QNAME;
-          GENV_ITEMFACTORY->createString( value_item, value );
-          GENV_ITEMFACTORY->createAttributeNode(
-            junk_item, cur_item, att_name, type_name, value_item
-          );
-
-          needs_type_attribute = true;
-          next_string_is_key = false;
-        } else {
-          ADD_ITEM_ELEMENT( "string" );
-          GENV_ITEMFACTORY->createTextNode( junk_item, cur_item, value );
-          POP_ITEM_ELEMENT();
-        }
-        break;
-
-      case 'F':
-      case 'T':
-        ADD_TYPE_ATTRIBUTE( "boolean" );
-        ADD_ITEM_ELEMENT( "boolean" );
-        value = token.get_type() == 'F' ? "false" : "true";
-        GENV_ITEMFACTORY->createTextNode( junk_item, cur_item, value );
-        POP_ITEM_ELEMENT();
-        break;
-
-      case json::token::json_null:
-        ADD_TYPE_ATTRIBUTE( "null" );
-        ADD_ITEM_ELEMENT( "null" );
-        POP_ITEM_ELEMENT();
-        break;
-
-      case ':':
-      case json::token::none:
+        PUSH_ITEM( json );
+        json_item = value_item;
+        PUSH_ITERATOR( cur_iter );
+        cur_iter = json_item->getObjectKeys();
+        cur_iter->open();
         break;
 
       default:
-        assert( false );
+        break;
     } // switch
+
+    if ( added_pair_element )
+      POP_ITEM( xml );
   } // while
-  if ( !got_something )
-    throw XQUERY_EXCEPTION( zerr::ZJPE0009_ILLEGAL_EMPTY_STRING );
 }
 
-} // namespace snelson
-
 ///////////////////////////////////////////////////////////////////////////////
 
-static void assert_json_type( json::type t, zstring const &s ) {
+// forward declarations
+static void x2j_item_element( store::Item_t const &item, store::Item_t *value );
+static void x2j_object( store::Item_t const &parent, store::Item_t *object );
+static void x2j_pair_element( store::Item_t const &pair, store::Item_t *key,
+                              store::Item_t *value );
+static void x2j_type( store::Item_t const &item, store::Item_t *value );
+
+static void assert_element_name( store::Item_t const &element,
+                                 char const *required_name ) {
+  zstring const element_name( name_of( element ) );
+  if ( element_name != required_name ) {
+    zstring parent_type;
+    if ( ::strcmp( required_name, "item" ) == 0 )
+      parent_type = "array";
+    else if ( ::strcmp( required_name, "pair" ) == 0 )
+      parent_type = "object";
+    throw XQUERY_EXCEPTION(
+      zerr::ZJSE0004_BAD_NODE,
+      ERROR_PARAMS( element_name, parent_type, required_name )
+    );
+  }
+}
+
+static void assert_json_type( json::type t, zstring const &s,
+                              json::token *ptoken = nullptr ) {
   // Doing it this way uses the string data in-place with no copy.
   mem_streambuf::char_type *const p =
     const_cast<mem_streambuf::char_type*>( s.data() );
@@ -230,15 +307,17 @@
 
   json::lexer lex( iss );
   json::token token;
+  if ( !ptoken )
+    ptoken = &token;
   try {
-    if ( lex.next( &token ) && json::map_type( token.get_type() ) == t )
+    if ( lex.next( ptoken ) && json::map_type( ptoken->get_type() ) == t )
       return;
   }
   catch ( json::exception const& ) {
     // do nothing
   }
   throw XQUERY_EXCEPTION(
-    zerr::ZJSE0008_BAD_VALUE,
+    zerr::ZJSE0008_BAD_ELEMENT_VALUE,
     ERROR_PARAMS( s, t )
   );
 }
@@ -246,10 +325,11 @@
 static void require_attribute_value( store::Item_t const &element,
                                      char const *att_name,
                                      zstring *att_value ) {
+  ZORBA_ASSERT( att_value );
   if ( !get_attribute_value( element, att_name, att_value ) )
     throw XQUERY_EXCEPTION(
       zerr::ZJSE0002_ELEMENT_MISSING_ATTRIBUTE,
-      ERROR_PARAMS( element->getNodeName()->getStringValue(), att_name )
+      ERROR_PARAMS( name_of( element ), att_name )
     );
 }
 
@@ -277,226 +357,388 @@
   );
 }
 
-inline std::ostream& if_space_or_newline( std::ostream &o,
-                                          whitespace::type ws ) {
-  if ( ws == whitespace::some )
-    o << ' ';
-  else
-    o << if_emit( ws == whitespace::indent, '\n' );
-  return o;
-}
-DEF_OMANIP1( if_space_or_newline, whitespace::type )
-
-static ostream& serialize_begin( ostream &o, json::type t,
-                                 whitespace::type ws ) {
-  switch ( t ) {
-    case json::array :
-      o << '[' << if_emit( ws, ' ' );
-      break;
-    case json::object:
-      o << '{' << if_space_or_newline( ws ) << if_indent( ws, inc_indent );
-      break;
-    default:
-      /* suppress warning */;
-  }
-  return o;
-}
-DEF_OMANIP2( serialize_begin, json::type, whitespace::type )
-
-static ostream& serialize_end( ostream &o, json::type t, whitespace::type ws ) {
-  switch ( t ) {
-    case json::array:
-      o << if_emit( ws, ' ' ) << ']';
-      break;
-    case json::object:
-      o << if_space_or_newline( ws ) << if_indent( ws, dec_indent )
-        << if_indent( ws, indent ) << '}';
-      break;
-    default:
-      /* suppress warning */;
-  }
-  return o;
-}
-DEF_OMANIP2( serialize_end, json::type, whitespace::type )
-
-static ostream& serialize_boolean( ostream &o, zstring const &s ) {
-  assert_json_type( json::boolean, s );
-  return o << s;
-}
-DEF_OMANIP1( serialize_boolean, zstring const& )
-
-static ostream& serialize_number( ostream &o, zstring const &s ) {
-  assert_json_type( json::number, s );
-  return o << s;
-}
-DEF_OMANIP1( serialize_number, zstring const& )
-
-static ostream& serialize_string( ostream &o, zstring const &s ) {
-  ostringstream oss;
-  oss << '"' << json::serialize( s ) << '"';
-  string const temp( oss.str() );
-  assert_json_type( json::string, temp );
-  return o << temp;
-}
-DEF_OMANIP1( serialize_string, zstring const& )
-
-static ostream& serialize_children( ostream&, store::Item_t const&, json::type,
-                                    whitespace::type );
-DEF_OMANIP3( serialize_children, store::Item_t const&, json::type,
-             whitespace::type )
-
-static ostream& serialize_json_element( ostream &o,
-                                        store::Item_t const &element,
-                                        whitespace::type ws ) {
-  zstring const element_name( element->getNodeName()->getStringValue() );
-  if ( element_name != "json" )
-    throw XQUERY_EXCEPTION(
-      zerr::ZJSE0004_BAD_ELEMENT,
-      ERROR_PARAMS( element_name, "json" )
-    );
-
-  json::type const t = get_json_type( element, false );
-
-  return o
-    << serialize_begin( t, ws )
-    << serialize_children( element, t, ws )
-    << serialize_end( t, ws );
-}
-DEF_OMANIP2( serialize_json_element, store::Item_t const&, whitespace::type )
-
-static ostream& serialize_item_element( ostream &o,
-                                        store::Item_t const &element,
-                                        whitespace::type ws ) {
-  zstring const element_name( element->getNodeName()->getStringValue() );
-  if ( element_name != "item" )
-    throw XQUERY_EXCEPTION(
-      zerr::ZJSE0005_BAD_CHILD_ELEMENT,
-      ERROR_PARAMS( element_name, "array", "item" )
-    );
-
-  json::type const t = get_json_type( element );
-
-  return o
-    << serialize_begin( t, ws )
-    << serialize_children( element, t, ws )
-    << serialize_end( t, ws );
-}
-DEF_OMANIP2( serialize_item_element, store::Item_t const&, whitespace::type )
-
-static ostream& serialize_pair_element( ostream &o,
-                                        store::Item_t const &element,
-                                        whitespace::type ws ) {
-  zstring const element_name( element->getNodeName()->getStringValue() );
-  if ( element_name != "pair" )
-    throw XQUERY_EXCEPTION(
-      zerr::ZJSE0005_BAD_CHILD_ELEMENT,
-      ERROR_PARAMS( element_name, "object", "pair" )
-    );
-
-  zstring name_att_value;
-  require_attribute_value( element, "name", &name_att_value );
-  json::type const t = get_json_type( element );
-
-  return o
-    << if_indent( ws, indent ) << serialize_string( name_att_value )
-    << if_emit( ws, ' ' ) << ':' << if_emit( ws, ' ' )
-    << serialize_begin( t, ws )
-    << serialize_children( element, t, ws )
-    << serialize_end( t, ws );
-}
-DEF_OMANIP2( serialize_pair_element, store::Item_t const&, whitespace::type )
-
-static ostream& serialize_children( ostream &o, store::Item_t const &parent,
-                                    json::type parent_type,
-                                    whitespace::type ws ) {
-  if ( parent_type == json::null )
-    o << "null";
-  else {
-    oseparator sep;
-    if ( ws == whitespace::none )
-      sep.sep( "," );
-    else if ( ws == whitespace::some || parent_type == json::array )
-      sep.sep( ", " );
-    else
-      sep.sep( ",\n" );
-
-    store::Iterator_t i = parent->getChildren();
-    i->open();
-    store::Item_t child;
-    while ( i->next( child ) ) {
-
-      switch ( child->getNodeKind() ) {
-
-        case store::StoreConsts::elementNode:
-          o << sep;
-          switch ( parent_type ) {
-            case json::none:
-              o << serialize_json_element( child, ws );
-              break;
-            case json::array:
-              o << serialize_item_element( child, ws );
-              break;
-            case json::object:
-              o << serialize_pair_element( child, ws );
-              break;
-            default:
-              throw XQUERY_EXCEPTION(
-                zerr::ZJSE0006_NO_ELEMENT_CHILD,
-                ERROR_PARAMS( json::type_string_of[ parent_type ] )
-              );
-          }
-          break;
-
-        case store::StoreConsts::textNode:
-          o << sep;
-          switch ( parent_type ) {
-            case json::boolean:
-              o << serialize_boolean( child->getStringValue() );
-              break;
-            case json::number:
-              o << serialize_number( child->getStringValue() );
-              break;
-            case json::string:
-              o << serialize_string( child->getStringValue() );
-              break;
-            default:
-              throw XQUERY_EXCEPTION(
-                zerr::ZJSE0007_NO_TEXT_CHILD,
-                ERROR_PARAMS( json::type_string_of[ parent_type ] )
-              );
-          }
-          break;
-
-        default:
-          // do nothing
-          break;
-      } // switch
-    } // while
-    i->close();
-  }
-  return o;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-namespace snelson {
-
-void serialize( ostream &o, store::Item_t const &item, whitespace::type ws ) {
-  switch ( item->getNodeKind() ) {
+static void x2j_array( store::Item_t const &parent, store::Item_t *array ) {
+  ZORBA_ASSERT( array );
+  vector<store::Item_t> elements;
+  store::Iterator_t i( parent->getChildren() );
+  i->open();
+  store::Item_t child, element;
+  while ( i->next( child ) ) {
+    switch ( child->getNodeKind() ) {
+      case store::StoreConsts::elementNode:
+        x2j_item_element( child, &element );
+        elements.push_back( element );
+        break;
+      case store::StoreConsts::commentNode:
+      case store::StoreConsts::piNode:
+        // ignore
+        break;
+      default:
+        throw XQUERY_EXCEPTION(
+          zerr::ZJSE0004_BAD_NODE,
+          ERROR_PARAMS( child->getNodeKind(), json::array )
+        );
+    } // switch
+  } // while
+  i->close();
+  GENV_ITEMFACTORY->createJSONArray( *array, elements );
+}
+
+static void x2j_boolean( store::Item_t const &parent, store::Item_t *boolean ) {
+  ZORBA_ASSERT( boolean );
+  bool got_value = false;
+  store::Iterator_t i( parent->getChildren() );
+  i->open();
+  store::Item_t child;
+  while ( i->next( child ) ) {
+    switch ( child->getKind() ) {
+
+      case store::Item::NODE:
+        switch ( child->getNodeKind() ) {
+          case store::StoreConsts::textNode: {
+            zstring const s( child->getStringValue() );
+            if ( got_value )
+              throw XQUERY_EXCEPTION(
+                zerr::ZJSE0009_MULTIPLE_CHILDREN,
+                ERROR_PARAMS( s, json::boolean )
+              );
+            if ( s == "false" )
+              GENV_ITEMFACTORY->createBoolean( *boolean, false );
+            else if ( s == "true" )
+              GENV_ITEMFACTORY->createBoolean( *boolean, true );
+            else
+              throw XQUERY_EXCEPTION(
+                zerr::ZJSE0008_BAD_ELEMENT_VALUE,
+                ERROR_PARAMS( s, json::boolean )
+              );
+            got_value = true;
+            break;
+          }
+          case store::StoreConsts::commentNode:
+          case store::StoreConsts::piNode:
+            // ignore
+            break;
+          default:
+            throw XQUERY_EXCEPTION(
+              zerr::ZJSE0004_BAD_NODE,
+              ERROR_PARAMS( child->getNodeKind(), json::boolean )
+            );
+        } // switch
+        break;
+
+      case store::Item::ATOMIC:
+        switch ( child->getTypeCode() ) {
+          case store::XS_BOOLEAN:
+            if ( got_value )
+              throw XQUERY_EXCEPTION(
+                zerr::ZJSE0009_MULTIPLE_CHILDREN,
+                ERROR_PARAMS( child->getStringValue(), json::boolean )
+              );
+            *boolean = child;
+            got_value = true;
+            break;
+          default:
+            throw XQUERY_EXCEPTION(
+              zerr::ZJSE0008_BAD_ELEMENT_VALUE,
+              ERROR_PARAMS( child->getStringValue(), json::boolean )
+            );
+        } // switch
+        break;
+
+      default:
+        throw XQUERY_EXCEPTION(
+          zerr::ZJSE0004_BAD_NODE,
+          ERROR_PARAMS( child->getKind(), json::boolean )
+        );
+    } // switch
+  } // while
+  i->close();
+  if ( !got_value )
+    throw XQUERY_EXCEPTION(
+      zerr::ZJSE0007_ELEMENT_MISSING_VALUE,
+      ERROR_PARAMS( name_of( parent ), json::boolean )
+    );
+}
+
+static void x2j_item_element( store::Item_t const &item,
+                              store::Item_t *value ) {
+  ZORBA_ASSERT( value );
+  assert_element_name( item, "item" );
+  x2j_type( item, value );
+}
+
+static void x2j_json_element( store::Item_t const &element,
+                              store::Item_t *json_item ) {
+  ZORBA_ASSERT( json_item );
+  assert_element_name( element, "json" );
+  switch ( get_json_type( element, false ) ) {
+    case json::array:
+      x2j_array( element, json_item );
+      break;
+    case json::object:
+      x2j_object( element, json_item );
+      break;
+    default:
+      ZORBA_ASSERT( false );
+  }
+}
+
+static void x2j_number( store::Item_t const &parent, store::Item_t *number ) {
+  ZORBA_ASSERT( number );
+  bool got_value = false;
+  store::Iterator_t i( parent->getChildren() );
+  i->open();
+  store::Item_t child;
+  while ( i->next( child ) ) {
+    switch ( child->getKind() ) {
+
+      case store::Item::NODE:
+        switch ( child->getNodeKind() ) {
+          case store::StoreConsts::textNode: {
+            zstring const s( child->getStringValue() );
+            if ( got_value )
+              throw XQUERY_EXCEPTION(
+                zerr::ZJSE0009_MULTIPLE_CHILDREN,
+                ERROR_PARAMS( s, json::number )
+              );
+            json::token token;
+            assert_json_type( json::number, s, &token );
+            switch ( token.get_numeric_type() ) {
+              case json::token::integer:
+                GENV_ITEMFACTORY->createInteger( *number, xs_integer( s ) );
+                break;
+              case json::token::decimal:
+                GENV_ITEMFACTORY->createDecimal( *number, xs_decimal( s ) );
+                break;
+              case json::token::floating_point:
+                GENV_ITEMFACTORY->createDouble( *number, xs_double( s ) );
+                break;
+              default:
+                ZORBA_ASSERT( false );
+            }
+            got_value = true;
+            break;
+          }
+          case store::StoreConsts::commentNode:
+          case store::StoreConsts::piNode:
+            // ignore
+            break;
+          default:
+            throw XQUERY_EXCEPTION(
+              zerr::ZJSE0004_BAD_NODE,
+              ERROR_PARAMS( child->getNodeKind(), json::number )
+            );
+        } // switch
+        break;
+
+      case store::Item::ATOMIC:
+        switch ( child->getTypeCode() ) {
+          case store::XS_BYTE:
+          case store::XS_DECIMAL:
+          case store::XS_DOUBLE:
+          case store::XS_FLOAT:
+          case store::XS_INT:
+          case store::XS_INTEGER:
+          case store::XS_LONG:
+          case store::XS_NEGATIVE_INTEGER:
+          case store::XS_NON_NEGATIVE_INTEGER:
+          case store::XS_NON_POSITIVE_INTEGER:
+          case store::XS_POSITIVE_INTEGER:
+          case store::XS_SHORT:
+          case store::XS_UNSIGNED_BYTE:
+          case store::XS_UNSIGNED_INT:
+          case store::XS_UNSIGNED_LONG:
+          case store::XS_UNSIGNED_SHORT:
+            if ( got_value )
+              throw XQUERY_EXCEPTION(
+                zerr::ZJSE0009_MULTIPLE_CHILDREN,
+                ERROR_PARAMS( child->getStringValue(), json::number )
+              );
+            *number = child;
+            got_value = true;
+            break;
+          default:
+            throw XQUERY_EXCEPTION(
+              zerr::ZJSE0008_BAD_ELEMENT_VALUE,
+              ERROR_PARAMS( child->getStringValue(), json::number )
+            );
+        } // switch
+        break;
+
+      default:
+        throw XQUERY_EXCEPTION(
+          zerr::ZJSE0004_BAD_NODE,
+          ERROR_PARAMS( child->getKind(), json::number )
+        );
+    } // switch
+  } // while
+  i->close();
+  if ( !got_value )
+    throw XQUERY_EXCEPTION(
+      zerr::ZJSE0007_ELEMENT_MISSING_VALUE,
+      ERROR_PARAMS( name_of( parent ), json::number )
+    );
+}
+
+static void x2j_object( store::Item_t const &parent, store::Item_t *object ) {
+  ZORBA_ASSERT( object );
+  vector<store::Item_t> keys, values;
+  store::Iterator_t i( parent->getChildren() );
+  i->open();
+  store::Item_t child, key, value;
+  while ( i->next( child ) ) {
+    switch ( child->getNodeKind() ) {
+      case store::StoreConsts::elementNode:
+        x2j_pair_element( child, &key, &value );
+        keys.push_back( key );
+        values.push_back( value );
+        break;
+      case store::StoreConsts::commentNode:
+      case store::StoreConsts::piNode:
+        // ignore
+        break;
+      default:
+        throw XQUERY_EXCEPTION(
+          zerr::ZJSE0004_BAD_NODE,
+          ERROR_PARAMS( child->getNodeKind(), json::object )
+        );
+    } // switch
+  } // while
+  i->close();
+  GENV_ITEMFACTORY->createJSONObject( *object, keys, values );
+}
+
+static void x2j_pair_element( store::Item_t const &pair, store::Item_t *key,
+                              store::Item_t *value ) {
+  ZORBA_ASSERT( value );
+  assert_element_name( pair, "pair" );
+  zstring key_name;
+  require_attribute_value( pair, "name", &key_name );
+  GENV_ITEMFACTORY->createString( *key, key_name );
+  x2j_type( pair, value );
+}
+
+static void x2j_string( store::Item_t const &parent, store::Item_t *string ) {
+  ZORBA_ASSERT( string );
+  bool got_value = false;
+  store::Iterator_t i( parent->getChildren() );
+  i->open();
+  store::Item_t child;
+  while ( i->next( child ) ) {
+    switch ( child->getKind() ) {
+
+      case store::Item::NODE:
+        switch ( child->getNodeKind() ) {
+          case store::StoreConsts::textNode: {
+            zstring value( child->getStringValue() );
+            if ( got_value )
+              throw XQUERY_EXCEPTION(
+                zerr::ZJSE0009_MULTIPLE_CHILDREN,
+                ERROR_PARAMS( name_of( parent ), json::string )
+              );
+            GENV_ITEMFACTORY->createString( *string, value );
+            got_value = true;
+            break;
+          }
+          case store::StoreConsts::commentNode:
+          case store::StoreConsts::piNode:
+            // ignore
+            break;
+          default:
+            throw XQUERY_EXCEPTION(
+              zerr::ZJSE0004_BAD_NODE,
+              ERROR_PARAMS( child->getNodeKind(), json::string )
+            );
+        }
+        break;
+
+      case store::Item::ATOMIC:
+        switch ( child->getTypeCode() ) {
+          case store::XS_ENTITY:
+          case store::XS_ID:
+          case store::XS_IDREF:
+          case store::XS_NAME:
+          case store::XS_NCNAME:
+          case store::XS_NMTOKEN:
+          case store::XS_NORMALIZED_STRING:
+          case store::XS_STRING:
+          case store::XS_TOKEN: {
+            if ( got_value )
+              throw XQUERY_EXCEPTION(
+                zerr::ZJSE0009_MULTIPLE_CHILDREN,
+                ERROR_PARAMS( name_of( parent ), json::string )
+              );
+            *string = child;
+            got_value = true;
+            break;
+          }
+          default:
+            throw XQUERY_EXCEPTION(
+              zerr::ZJSE0008_BAD_ELEMENT_VALUE,
+              ERROR_PARAMS( child->getStringValue(), json::string )
+            );
+        }
+        break;
+
+      default:
+        throw XQUERY_EXCEPTION(
+          zerr::ZJSE0004_BAD_NODE,
+          ERROR_PARAMS( child->getKind(), json::string )
+        );
+    } // switch
+  } // while
+  i->close();
+  if ( !got_value )
+    throw XQUERY_EXCEPTION(
+      zerr::ZJSE0007_ELEMENT_MISSING_VALUE,
+      ERROR_PARAMS( name_of( parent ), json::boolean )
+    );
+}
+
+static void x2j_type( store::Item_t const &xml_item,
+                      store::Item_t *json_item ) {
+  ZORBA_ASSERT( json_item );
+  switch ( get_json_type( xml_item ) ) {
+    case json::array:
+      x2j_array( xml_item, json_item );
+      break;
+    case json::object:
+      x2j_object( xml_item, json_item );
+      break;
+    case json::boolean:
+      x2j_boolean( xml_item, json_item );
+      break;
+    case json::null:
+      GENV_ITEMFACTORY->createJSONNull( *json_item );
+      break;
+    case json::number:
+      x2j_number( xml_item, json_item );
+      break;
+    case json::string:
+      x2j_string( xml_item, json_item );
+      break;
+    case json::none:
+      ZORBA_ASSERT( false );
+  } // switch
+}
+
+void xml_to_json( store::Item_t const &xml_item, store::Item_t *json_item ) {
+  ZORBA_ASSERT( json_item );
+  switch ( xml_item->getNodeKind() ) {
     case store::StoreConsts::documentNode:
-      o << serialize_children( item, json::none, ws );
+      // TODO
+      //serialize_children( xml_item, json::none );
       break;
     case store::StoreConsts::elementNode:
-      o << serialize_json_element( item, ws );
+      x2j_json_element( xml_item, json_item );
       break;
     default:
       throw XQUERY_EXCEPTION( zerr::ZJSE0001_NOT_DOCUMENT_OR_ELEMENT_NODE );
   }
 }
 
+///////////////////////////////////////////////////////////////////////////////
+
 } // namespace snelson
-
-///////////////////////////////////////////////////////////////////////////////
-
 } // namespace zorba
 /* vim:set et sw=2 ts=2: */

=== modified file 'src/runtime/json/snelson.h'
--- src/runtime/json/snelson.h	2011-12-27 01:15:25 +0000
+++ src/runtime/json/snelson.h	2013-07-26 23:55:36 +0000
@@ -21,7 +21,6 @@
 #include <iostream>
 
 #include "store/api/item.h"
-#include "util/json_parser.h"
 
 #include "common.h"
 
@@ -30,8 +29,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void parse( json::parser &p, store::Item_t *result );
-void serialize( std::ostream&, store::Item_t const &item, whitespace::type );
+void json_to_xml( store::Item_t const &json_item, store::Item_t *xml_item );
+void xml_to_json( store::Item_t const &xml_item, store::Item_t *json_item );
 
 ///////////////////////////////////////////////////////////////////////////////
 

=== modified file 'src/runtime/spec/json/json.xml'
--- src/runtime/spec/json/json.xml	2013-07-11 00:46:02 +0000
+++ src/runtime/spec/json/json.xml	2013-07-26 23:55:36 +0000
@@ -1,52 +1,41 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!--
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
--->
 <zorba:iterators
   xmlns:zorba="http://www.zorba-xquery.com";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
 
-<!--
-/*******************************************************************************
-*******************************************************************************/
--->
+<!--////////////////////////////////////////////////////////////////////////-->
+
 <zorba:iterator name="JSONtoXMLInternal" arity="nary">
-
   <zorba:description author="Zorba Team">
     function for parsing strings into json-xdm
   </zorba:description>
-
   <zorba:function isDeterministic="true">
     <zorba:signature localname="json-to-xml-internal" prefix="fn-zorba-json">
-      <zorba:param>xs:string</zorba:param>
-      <zorba:param>item()?</zorba:param>
-      <zorba:output>element()*</zorba:output>
+      <zorba:param>json-item()?</zorba:param>
+      <zorba:param>object()</zorba:param>
+      <zorba:output>element()?</zorba:output>
     </zorba:signature>
   </zorba:function>
-
 </zorba:iterator>
 
-<!--
-/*******************************************************************************
-*******************************************************************************/
--->
+<!--////////////////////////////////////////////////////////////////////////-->
+
 <zorba:iterator name="XMLtoJSONInternal" arity="nary">
-
   <zorba:description author="Zorba Team">
     Function to serialize json/jsonml xdm to string
   </zorba:description>
-
   <zorba:function isDeterministic="true">
     <zorba:signature localname="xml-to-json-internal" prefix="fn-zorba-json">
       <zorba:param>item()*</zorba:param>
-      <zorba:param>item()?</zorba:param>
-      <zorba:output>xs:string</zorba:output>
+      <zorba:param>object()</zorba:param>
+      <zorba:output>json-item()*</zorba:output>
     </zorba:signature>
   </zorba:function>
-
 </zorba:iterator>
 
+<!--////////////////////////////////////////////////////////////////////////-->
+
 </zorba:iterators>
+<!-- vim:set et sw=2 ts=2: -->

=== modified file 'src/store/api/item.h'
--- src/store/api/item.h	2013-07-11 14:04:33 +0000
+++ src/store/api/item.h	2013-07-26 23:55:36 +0000
@@ -61,7 +61,7 @@
 {
 public:
   enum ItemKind
-  {
+  { // If you change this, also change operator<<(ostream&,ItemKind).
     NODE       = 0x0,
     ATOMIC     = 0x1,
     PUL        = 0x3, 
@@ -1030,6 +1030,11 @@
   Item& operator=(const Item&);
 };
 
+ZORBA_DLL_PUBLIC
+std::ostream& operator<<( std::ostream&, Item::ItemKind );
+
+///////////////////////////////////////////////////////////////////////////////
+
 } // namespace store
 } // namespace zorba
 

=== modified file 'src/store/naive/item.cpp'
--- src/store/naive/item.cpp	2013-06-27 15:54:27 +0000
+++ src/store/naive/item.cpp	2013-07-26 23:55:36 +0000
@@ -1490,6 +1490,23 @@
   );
 }
 
+std::ostream& operator<<( std::ostream &o, Item::ItemKind k ) {
+  switch ( k ) {
+    case Item::NODE:      o << "node";      break;
+    case Item::ATOMIC:    o << "atomic";    break;
+    case Item::PUL:       o << "pul";       break;
+    case Item::FUNCTION:  o << "function";  break;
+    case Item::LIST:      o << "list";      break;
+    case Item::OBJECT:    o << "object";    break;
+    case Item::ARRAY:     o << "array";     break;
+    case Item::ERROR_:    o << "error";     break;
+    default:
+      o << "<unknown ItemKind: " << (int)k << '>';
+  }
+  return o;
+}
+
+///////////////////////////////////////////////////////////////////////////////
 
 } // namespace store
 } // namespace zorba

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-01.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+<li>list item</li>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-02.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-02.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,4 @@
+<ul>
+  <li>list item 1</li>
+  <li>list item 2</li>
+</ul>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-03.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-03.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+<file dir="/tmp" name="foo" size="1234" modified="2006-12-31T23:59"/>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-04.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-04.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,5 @@
+<ul>
+  <li style="color:red">First Item</li>
+  <li title="Some hover text." style="color:green">Second Item</li>
+  <li><span class="code-example-third">Third</span> Item</li>
+</ul>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-05.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-05.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,14 @@
+<table class="MyTable" style="background-color:yellow">
+  <tr>
+    <td class="MyTD" style="border:1px solid black">#550758</td>
+    <td class="MyTD" style="background-color:red">Example text here</td>
+  </tr>
+  <tr>
+    <td class="MyTD" style="border:1px solid black">#993101</td>
+    <td class="MyTD" style="background-color:green">127624015</td>
+  </tr>
+  <tr>
+    <td class="MyTD" style="border:1px solid black">#E33D87</td>
+    <td class="MyTD" style="background-color:blue"> <span style="background-color:maroon">©</span> </td>
+  </tr>
+</table>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-wikipedia.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-wikipedia.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-j2x-wikipedia.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,10 @@
+<person created="2006-11-11T19:23" modified="2006-12-31T23:59">
+  <firstName>Robert</firstName>
+  <lastName>Smith</lastName>
+  <address type="home">
+    <street>12345 Sixth Ave</street>
+    <city>Anytown</city>
+    <state>CA</state>
+    <postalCode>98765-4321</postalCode>
+  </address>
+</person>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-01.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+[ "li", "list item" ]

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-02.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-02.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+[ "ul", [ "li", "list item 1" ], [ "li", "list item 2" ] ]

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-03.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-03.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+[ "file", { "dir" : "/tmp", "name" : "foo", "size" : "1234", "modified" : "2006-12-31T23:59" } ]

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-wikipedia.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-wikipedia.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jmla-x2j-wikipedia.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+[ "person", { "created" : "2006-11-11T19:23", "modified" : "2006-12-31T23:59" }, [ "firstName", "Robert" ], [ "lastName", "Smith" ], [ "address", { "type" : "home" }, [ "street", "12345 Sixth Ave" ], [ "city", "Anytown" ], [ "state", "CA" ], [ "postalCode", "98765-4321" ] ] ]

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-01.xml.res	2011-12-23 06:21:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-01.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-<li>list item</li>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-02.xml.res	2011-12-23 06:21:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-02.xml.res	1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
-<ul>
-  <li>list item 1</li>
-  <li>list item 2</li>
-</ul>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-03.xml.res	2011-12-23 06:21:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-03.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-<file dir="/tmp" name="foo" size="1234" modified="2006-12-31T23:59"/>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-04.xml.res	2012-01-23 23:22:52 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-04.xml.res	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-<ul>
-  <li style="color:red">First Item</li>
-  <li title="Some hover text." style="color:green">Second Item</li>
-  <li>
-    <span class="code-example-third">Third Item</span>
-  </li>
-</ul>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-05.xml.res	2012-01-23 23:22:52 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-05.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-<table class="MyTable" style="background-color:yellow"><tr><td class="MyTD" style="border:1px solid black">#550758</td><td class="MyTD" style="background-color:red">Example text here</td></tr><tr><td class="MyTD" style="border:1px solid black">#993101</td><td class="MyTD" style="background-color:green">127624015</td></tr><tr><td class="MyTD" style="border:1px solid black">#E33D87</td><td class="MyTD" style="background-color:blue"> <span style="background-color:maroon">© </span></td></tr></table>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-wikipedia.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-wikipedia.xml.res	2011-12-23 06:21:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-parse-wikipedia.xml.res	1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
-<person created="2006-11-11T19:23" modified="2006-12-31T23:59">
-  <firstName>Robert</firstName>
-  <lastName>Smith</lastName>
-  <address type="home">
-    <street>12345 Sixth Ave</street>
-    <city>Anytown</city>
-    <state>CA</state>
-    <postalCode>98765-4321</postalCode>
-  </address>
-</person>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-01.xml.res	2011-12-23 06:21:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-01.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-["li","list item"]

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-02.xml.res	2011-12-23 06:21:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-02.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-["ul",["li","list item 1"],["li","list item 2"]]

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-03.xml.res	2011-12-23 06:21:58 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-03.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-["file",{"dir":"/tmp","name":"foo","size":"1234","modified":"2006-12-31T23:59"}]

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xml.res	2011-12-28 05:41:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xml.res	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
-[ "person", 
-  { "created" : "2006-11-11T19:23",
-    "modified" : "2006-12-31T23:59" }, 
-  [ "firstName", "Robert" ], 
-  [ "lastName", "Smith" ], 
-  [ "address", 
-    { "type" : "home" }, 
-    [ "street", "12345 Sixth Ave" ], 
-    [ "city", "Anytown" ], 
-    [ "state", "CA" ], 
-    [ "postalCode", "98765-4321" ] ] ]

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-none-wikipedia.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-none-wikipedia.xml.res	2011-12-28 05:41:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-none-wikipedia.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-["person",{"created":"2006-11-11T19:23","modified":"2006-12-31T23:59"},["firstName","Robert"],["lastName","Smith"],["address",{"type":"home"},["street","12345 Sixth Ave"],["city","Anytown"],["state","CA"],["postalCode","98765-4321"]]]

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-some-wikipedia.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-some-wikipedia.xml.res	2011-12-28 05:41:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-jsonml_array-serialize-some-wikipedia.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-[ "person", { "created" : "2006-11-11T19:23", "modified" : "2006-12-31T23:59" }, [ "firstName", "Robert" ], [ "lastName", "Smith" ], [ "address", { "type" : "home" }, [ "street", "12345 Sixth Ave" ], [ "city", "Anytown" ], [ "state", "CA" ], [ "postalCode", "98765-4321" ] ] ]

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-01.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,3 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="boolean">true</item>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-02.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-02.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,3 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="boolean">false</item>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-03.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-03.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,3 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="null"/>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-04.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-04.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,3 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="number">1</item>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-05.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-05.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,4 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="number">1</item>
+  <item type="number">2</item>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-06.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-06.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-06.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,8 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="object">
+    <pair name="key1" type="string">value1</pair>
+  </item>
+  <item type="object">
+    <pair name="key2" type="string">value2</pair>
+  </item>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-07.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-07.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-07.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,10 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="array">
+    <item type="number">11</item>
+    <item type="number">12</item>
+  </item>
+  <item type="array">
+    <item type="number">21</item>
+    <item type="number">22</item>
+  </item>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-08.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-08.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-array-08.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
+  <item type="number">1</item>
+  <item type="object">
+    <pair name="foo" type="string">bar</pair>
+  </item>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-example.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-example.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-example.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,14 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="firstName" type="string">John</pair>
+  <pair name="lastName" type="string">Smith</pair>
+  <pair name="address" type="object">
+    <pair name="streetAddress" type="string">21 2nd Street</pair>
+    <pair name="city" type="string">New York</pair>
+    <pair name="state" type="string">NY</pair>
+    <pair name="postalCode" type="number">10021</pair>
+  </pair>
+  <pair name="phoneNumbers" type="array">
+    <item type="string">212 732-1234</item>
+    <item type="string">646 123-4567</item>
+  </pair>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-numbers.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-numbers.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-numbers.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,5 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="decimal" type="number">2.89</pair>
+  <pair name="e" type="number">2.0E6</pair>
+  <pair name="negative" type="number">-1.89</pair>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-01.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,3 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="a" type="number">1</pair>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-02.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-02.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,4 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="a" type="number">1</pair>
+  <pair name="b" type="number">2</pair>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-03.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-03.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,8 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="k1" type="array">
+    <item type="object">
+      <pair name="k2" type="string">v2</pair>
+    </item>
+    <item type="null"/>
+  </pair>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-04.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-04.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="key1" type="array">
+    <item type="number">1</item>
+  </pair>
+  <pair name="key2" type="string">value</pair>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-05.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-object-05.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,3 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="a" type="null"/>
+</json>

=== added file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-utf8-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-utf8-01.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-j2x-utf8-01.xml.res	2013-07-26 23:55:36 +0000
@@ -0,0 +1,3 @@
+<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
+  <pair name="mdash" type="string">–</pair>
+</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-01.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-01.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="boolean">true</item>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-02.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-02.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="boolean">false</item>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-03.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-03.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="null"/>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-04.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-04.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="number">1</item>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-05.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-05.xml.res	1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="number">1</item>
-  <item type="number">2</item>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-06.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-06.xml.res	2012-01-26 01:35:11 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-06.xml.res	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="object">
-    <pair name="key1" type="string">value1</pair>
-  </item>
-  <item type="object">
-    <pair name="key2" type="string">value2</pair>
-  </item>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-07.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-07.xml.res	2012-01-26 01:47:19 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-07.xml.res	1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="array">
-    <item type="number">11</item>
-    <item type="number">12</item>
-  </item>
-  <item type="array">
-    <item type="number">21</item>
-    <item type="number">22</item>
-  </item>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-08.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-08.xml.res	2012-02-08 01:15:26 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-array-08.xml.res	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="array">
-  <item type="number">1</item>
-  <item type="object">
-    <pair name="foo" type="string">bar</pair>
-  </item>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-example.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-example.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-example.xml.res	1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="firstName" type="string">John</pair>
-  <pair name="lastName" type="string">Smith</pair>
-  <pair name="address" type="object">
-    <pair name="streetAddress" type="string">21 2nd Street</pair>
-    <pair name="city" type="string">New York</pair>
-    <pair name="state" type="string">NY</pair>
-    <pair name="postalCode" type="number">10021</pair>
-  </pair>
-  <pair name="phoneNumbers" type="array">
-    <item type="string">212 732-1234</item>
-    <item type="string">646 123-4567</item>
-  </pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="decimal" type="number">2.89</pair>
-  <pair name="e" type="number">2E+6</pair>
-  <pair name="negative" type="number">-1.89</pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-01.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-01.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="a" type="number">1</pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-02.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-02.xml.res	1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="a" type="number">1</pair>
-  <pair name="b" type="number">2</pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-03.xml.res	2012-02-08 15:45:53 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-03.xml.res	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="k1" type="array">
-    <item type="object">
-      <pair name="k2" type="string">v2</pair>
-    </item>
-    <item type="null"/>
-  </pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-04.xml.res	2012-02-13 17:25:08 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-04.xml.res	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="key1" type="array">
-    <item type="number">1</item>
-  </pair>
-  <pair name="key2" type="string">value</pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="a" type="null"/>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-serialize.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-serialize.xml.res	2012-01-23 23:22:52 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-serialize.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="html" type="string">&lt;b&gt;bold&lt;/b&gt;</pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-uncommon-chars.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-uncommon-chars.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-uncommon-chars.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="web-app" type="string">!_"-\?*.$+</pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-utf8-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-utf8-01.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-utf8-01.xml.res	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="mdash" type="string">–</pair>
-</json>

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-indent-example.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-indent-example.xml.res	2011-12-28 05:41:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-indent-example.xml.res	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
-{
-  "firstName" : "John",
-  "lastName" : "Smith",
-  "address" : {
-    "streetAddress" : "21 2nd Street",
-    "city" : "New York",
-    "state" : "NY",
-    "postalCode" : 10021
-  },
-  "phoneNumbers" : [ "212 732-1234", "646 123-4567" ]
-}

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-none-example.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-none-example.xml.res	2011-12-28 05:41:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-none-example.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-{"firstName":"John","lastName":"Smith","address":{"streetAddress":"21 2nd Street","city":"New York","state":"NY","postalCode":10021},"phoneNumbers":["212 732-1234","646 123-4567"]}

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-parse.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-parse.xml.res	2012-02-02 19:55:12 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-parse.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-{"key":"value"}

=== removed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-some-example.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-some-example.xml.res	2011-12-28 05:41:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-some-example.xml.res	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-{ "firstName" : "John", "lastName" : "Smith", "address" : { "streetAddress" : "21 2nd Street", "city" : "New York", "state" : "NY", "postalCode" : 10021 }, "phoneNumbers" : [ "212 732-1234", "646 123-4567" ] }

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-01.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-01.xml.res	2013-02-07 17:24:36 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-01.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-[true]
+[ true ]

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-02.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-02.xml.res	2011-12-22 04:01:56 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-02.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-[false]
+[ false ]

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-03.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-03.xml.res	2011-12-22 04:01:56 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-03.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-[null]
+[ null ]

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-04.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-04.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-04.xml.res	2011-12-22 04:01:56 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-04.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-[1]
+[ 1 ]

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-05.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-05.xml.res	2011-12-22 04:01:56 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-05.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-[1,2]
+[ 1, 2 ]

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-12.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-12.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-array-12.xml.res	2012-01-23 23:22:52 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-array-12.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-[true]
+[ true ]

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-object-01.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-object-01.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-object-01.xml.res	2011-12-22 04:01:56 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-object-01.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-{"a":1}
+{ "a" : 1 }

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-object-02.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-object-02.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-object-02.xml.res	2011-12-22 04:01:56 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-object-02.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-{"a":1,"b":2}
+{ "a" : 1, "b" : 2 }

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-object-03.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-object-03.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-serialize-object-03.xml.res	2012-01-23 23:22:52 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-x2j-object-03.xml.res	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-{"a":1}
+{ "a" : 1 }

=== modified file 'test/rbkt/Queries/zorba/error/data-location-json-2.xq'
--- test/rbkt/Queries/zorba/error/data-location-json-2.xq	2013-07-11 06:12:53 +0000
+++ test/rbkt/Queries/zorba/error/data-location-json-2.xq	2013-07-26 23:55:36 +0000
@@ -1,12 +1,12 @@
 import module namespace file = "http://expath.org/ns/file";;
-import module namespace jx = "http://zorba.io/modules/json-xml";;
+import module namespace jn = "http://jsoniq.org/functions";;
 declare namespace zerr = "http://zorba.io/modules/zorba-errors";;
 
 let $file := "$RBKT_SRC_DIR/Queries/zorba/error/data-location.json"
 let $json := file:read-text( $file )
 return
   try {
-    jx:json-to-xml( $json )
+    jn:parse-json( $json )
   }
   catch * {
     file:base-name( $zerr:data-uri ),

=== modified file 'test/rbkt/Queries/zorba/json/json-invalid-option-parameter.xq'
--- test/rbkt/Queries/zorba/json/json-invalid-option-parameter.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-invalid-option-parameter.xq	2013-07-26 23:55:36 +0000
@@ -1,6 +1,7 @@
-(: try parsing a valid JSON string with invalid JSON option parameter :)
+(: try parsing a valid JSON string with an invalid JSON $options parameter :)
 
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
+let $json := '{}'
 let $options := { "json-format" : "array" }
-return jx:json-to-xml('{}',$options)
+return jx:json-string-to-xml( $json, $options )

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-01.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-01.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-01.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,9 @@
+(: Simple JsonML :)
+
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ "li", "list item" ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-02.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-02.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-02.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,13 @@
+(: Multi-level JsonML :)
+
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json :=
+  [ "ul",
+    [ "li", "list item 1" ],
+    [ "li", "list item 2" ]
+  ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-03.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-03.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-03.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,17 @@
+(: JsonML with attributes :)
+
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json :=
+  [ "file",
+    {
+      "dir" : "/tmp",
+      "name" : "foo",
+      "size" : 1234,
+      "modified" : "2006-12-31T23:59"
+    }
+  ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-04.spec'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-04.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-04.spec	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+Comparison: Fragment

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-04.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-04.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-04.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,27 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json :=
+  [ "ul",
+    [ "li",
+      { "style" : "color:red" },
+      "First Item"
+    ],
+    [ "li",
+      {
+        "title" : "Some hover text.",
+        "style" : "color:green"
+      },
+      "Second Item"
+    ],
+    [ "li",
+      [ "span",
+        { "class" : "code-example-third" },
+        "Third"
+      ],
+      " Item"
+    ]
+  ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:se et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-05.spec'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-05.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-05.spec	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+Comparison: Fragment

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-05.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-05.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-05.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,70 @@
+jsoniq version "1.0";
+
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $j :=
+  [ "table",
+    {
+      "class" : "MyTable",
+      "style" : "background-color:yellow"
+    },
+    [ "tr",
+      [ "td",
+        {
+          "class" : "MyTD",
+          "style" : "border:1px solid black"
+        },
+        "#550758"
+      ],
+      [ "td",
+        {
+          "class" : "MyTD",
+          "style" : "background-color:red"
+        },
+        "Example text here"
+      ]
+    ],
+    [ "tr",
+      [ "td",
+        {
+          "class" : "MyTD",
+          "style" : "border:1px solid black"
+        },
+        "#993101"
+      ],
+      [ "td",
+        {
+          "class" : "MyTD",
+          "style" : "background-color:green"
+        },
+        "127624015"
+      ]
+    ],
+    [ "tr",
+      [ "td",
+      {
+        "class" : "MyTD",
+        "style" : "border:1px solid black"
+      },
+      "#E33D87"
+      ],
+      [ "td",
+        {
+          "class" : "MyTD",
+          "style" : "background-color:blue"
+        },
+        "\u00A0",
+        [ "span",
+          {
+            "style" : "background-color:maroon"
+          },
+          "\u00A9"
+        ],
+        "\u00A0"
+      ]
+    ]
+  ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $j, $options )
+
+(: vim:se et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-06.spec'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-06.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-06.spec	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+Error: http://zorba.io/modules/zorba-errors:ZJ2X0001

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-06.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-06.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-06.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,9 @@
+(: try parsing an empty value :)
+
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-07.spec'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-07.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-07.spec	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+Error: http://zorba.io/modules/zorba-errors:ZJ2X0001

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-07.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-07.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-07.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,7 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := { "args" : [ "<div><span>foo:</span> parse</div>" ] }
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-08.spec'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-08.spec	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-08.spec	2013-07-26 23:55:36 +0000
@@ -0,0 +1,1 @@
+Error: http://zorba.io/modules/zorba-errors:ZJ2X0001

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-08.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-08.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-08.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,7 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ { "x" : "x" } ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-j2x-wikipedia.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-j2x-wikipedia.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-j2x-wikipedia.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,20 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json :=
+  [ "person",
+    { "created" : "2006-11-11T19:23",
+      "modified" : "2006-12-31T23:59" },
+    [ "firstName", "Robert" ],
+    [ "lastName", "Smith" ],
+    [ "address",
+      { "type" : "home" },
+      [ "street", "12345 Sixth Ave" ],
+      [ "city", "Anytown" ],
+      [ "state", "CA" ],
+      [ "postalCode", "98765-4321" ]
+    ]
+  ]
+let $options := { "json-format" : "JsonML-array" }
+return jx:json-to-xml( $json, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-01.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-x2j-01.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-x2j-01.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,7 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $xml := <li>list item</li>
+let $options := { "json-format" : "JsonML-array" }
+return jx:xml-to-json( $xml, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-02.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-x2j-02.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-x2j-02.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,11 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $xml :=
+  <ul>
+    <li>list item 1</li>
+    <li>list item 2</li>
+  </ul>
+let $options := { "json-format" : "JsonML-array" }
+return jx:xml-to-json( $xml, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-03.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-x2j-03.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-x2j-03.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,8 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $xml :=
+  <file dir="/tmp" name="foo" size="1234" modified="2006-12-31T23:59"/>
+let $options := { "json-format" : "JsonML-array" }
+return jx:xml-to-json( $xml, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-jmla-x2j-wikipedia.xq'
--- test/rbkt/Queries/zorba/json/json-jmla-x2j-wikipedia.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jmla-x2j-wikipedia.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,17 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $xml :=
+  <person created="2006-11-11T19:23" modified="2006-12-31T23:59">
+    <firstName>Robert</firstName>
+    <lastName>Smith</lastName>
+    <address type="home">
+      <street>12345 Sixth Ave</street>
+      <city>Anytown</city>
+      <state>CA</state>
+      <postalCode>98765-4321</postalCode>
+    </address>
+  </person>
+let $options := { "json-format" : "JsonML-array" }
+return jx:xml-to-json( $xml, $options )
+
+(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '[ "li", "list item" ]'
-let $options := { "json-format" : "JsonML-array" }
-return jx:json-to-xml( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq	1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '
-  [ "ul",
-    [ "li", "list item 1" ],
-    [ "li", "list item 2" ]
-  ]
-'
-let $options := { "json-format" : "JsonML-array" }
-return jx:json-to-xml( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq	1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '
-  [ "file",
-    {
-      "dir" : "/tmp",
-      "name" : "foo",
-      "size" : 1234,
-      "modified" : "2006-12-31T23:59"
-    }
-  ]
-'
-let $options := { "json-format" : "JsonML-array" }
-return jx:json-to-xml( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq	1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '
-  [ "ul",
-    [ "li",
-      { "style" : "color:red" },
-      "First Item"
-    ],
-    [ "li",
-      {
-        "title" : "Some hover text.",
-        "style" : "color:green"
-      },
-      "Second Item"
-    ],
-    [ "li",
-      [ "span",
-        { "class" : "code-example-third" },
-        "Third"
-      ],
-      " Item"
-    ]
-  ]'
-let $options := { "json-format" : "JsonML-array" }
-return jx:json-to-xml( $json, $options )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq	1970-01-01 00:00:00 +0000
@@ -1,65 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '["table",
-{
-"class" : "MyTable",
-"style" : "background-color:yellow"
-},
-["tr",
-["td",
-{
-"class" : "MyTD",
-"style" : "border:1px solid black"
-},
-"#550758"
-],
-["td",
-{
-"class" : "MyTD",
-"style" : "background-color:red"
-},
-"Example text here"
-]
-],
-["tr",
-["td",
-{
-"class" : "MyTD",
-"style" : "border:1px solid black"
-},
-"#993101"
-],
-["td",
-{
-"class" : "MyTD",
-"style" : "background-color:green"
-},
-"127624015"
-]
-],
-["tr",
-["td",
-{
-"class" : "MyTD",
-"style" : "border:1px solid black"
-},
-"#E33D87"
-],
-["td",
-{
-"class" : "MyTD",
-"style" : "background-color:blue"
-},
-"\u00A0",
-["span",
-{ "style" : "background-color:maroon" },
-"\u00A9"
-],
-"\u00A0"
-]
-]
-]'
-let $options := { "json-format" : "JsonML-array" }
-return jx:json-to-xml( $json, $options )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.spec'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJPE0009

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-(: try parsing an empty value :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $options := { "json-format" : "JsonML-array" }
-return jx:json-to-xml( <a/>, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.spec'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJPE0010

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-07.xq	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
-import module namespace jx =
-  "http://zorba.io/modules/json-xml";;
-
-let $options := { "json-format" : "JsonML-array" }
-let $json :=
-  '{
-    "args": [ "<div><span>foo:</span> parse</div>" ]
-   }'
-return jx:json-to-xml( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.spec'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJPE0006

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-08.xq	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-import module namespace jx =
-  "http://zorba.io/modules/json-xml";;
-
-let $options := { "json-format" : "JsonML-array" }
-let $json := '[ { "x" : "x" } ]'
-return jx:json-to-xml( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '
-  [ "person",
-    { "created" : "2006-11-11T19:23",
-      "modified" : "2006-12-31T23:59" },
-    [ "firstName", "Robert" ],
-    [ "lastName", "Smith" ],
-    [ "address",
-      { "type" : "home" },
-      [ "street", "12345 Sixth Ave" ],
-      [ "city", "Anytown" ],
-      [ "state", "CA" ],
-      [ "postalCode", "98765-4321" ]
-    ]
-  ]
-'
-let $options := { "json-format" : "JsonML-array" }
-return jx:json-to-xml( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <li>list item</li>
-let $options := { "json-format" : "JsonML-array" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <ul>
-    <li>list item 1</li>
-    <li>list item 2</li>
-  </ul>
-let $options := { "json-format" : "JsonML-array" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <file dir="/tmp" name="foo" size="1234" modified="2006-12-31T23:59"/>
-let $options := { "json-format" : "JsonML-array" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <person created="2006-11-11T19:23" modified="2006-12-31T23:59">
-    <firstName>Robert</firstName>
-    <lastName>Smith</lastName>
-    <address type="home">
-      <street>12345 Sixth Ave</street>
-      <city>Anytown</city>
-      <state>CA</state>
-      <postalCode>98765-4321</postalCode>
-    </address>
-  </person>
-let $options := { "json-format" : "JsonML-array", "whitespace" : "indent" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <person created="2006-11-11T19:23" modified="2006-12-31T23:59">
-    <firstName>Robert</firstName>
-    <lastName>Smith</lastName>
-    <address type="home">
-      <street>12345 Sixth Ave</street>
-      <city>Anytown</city>
-      <state>CA</state>
-      <postalCode>98765-4321</postalCode>
-    </address>
-  </person>
-let $options := { "json-format" : "JsonML-array" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq	1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <person created="2006-11-11T19:23" modified="2006-12-31T23:59">
-    <firstName>Robert</firstName>
-    <lastName>Smith</lastName>
-    <address type="home">
-      <street>12345 Sixth Ave</street>
-      <city>Anytown</city>
-      <state>CA</state>
-      <postalCode>98765-4321</postalCode>
-    </address>
-  </person>
-let $options := { "json-format" : "JsonML-array", "whitespace" : "some" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-invalid-json.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-invalid-json.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-invalid-json.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJPE0006

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-invalid-json.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-invalid-json.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-invalid-json.xq	1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml('[ "ul",
-            	[ "li", true],
-                  [ "li",
-                    {"href":"driving.html", "title":"Driving"},
-                    "Second item"],
-                  [ "li", null],
-                  [ "li", -14e12]')

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-01.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-01.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ true() ]
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-02.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-02.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ false() ]
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-03.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-03.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ null ]
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-04.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-04.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-04.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ 1 ]
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-05.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-05.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ 1, 2 ]
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-06.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-06.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-06.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ { "key1" : "value1" }, { "key2" : "value2" } ]
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-07.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-07.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-07.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ [ 11, 12 ], [ 21, 22 ] ]
+return jx:json-to-xml( $json )
+
+(: vim:se et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-array-08.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-array-08.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-array-08.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := [ 1, { "foo" : "bar" } ]
+return jx:json-to-xml( $json )
+
+(: vim:se et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-example.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-example.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,20 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json :=
+  {
+    "firstName": "John",
+    "lastName": "Smith",
+    "address": {
+      "streetAddress": "21 2nd Street",
+      "city": "New York",
+      "state": "NY",
+      "postalCode": 10021
+    },
+    "phoneNumbers": [
+      "212 732-1234",
+      "646 123-4567"
+    ]
+  }
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-numbers.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-numbers.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-numbers.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,10 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := {
+  "decimal" : 2.89,
+  "e" : 2E+6,
+  "negative" : -1.89
+}
+return jx:json-to-xml( $json )
+
+(: vim:se et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-object-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-object-01.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-object-01.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := { "a" : 1 }
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-object-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-object-02.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-object-02.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := { "a" : 1, "b" : 2 }
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-object-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-object-03.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-object-03.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := { "k1" : [ { "k2" : "v2" }, null ] }
+return jx:json-to-xml( $json )
+
+(: vim:se et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-object-04.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-object-04.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-object-04.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,10 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json :=
+  {
+    "key1": [ 1 ],
+    "key2": "value"
+  }
+return jx:json-to-xml( $json )
+
+(: vim:se et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-object-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-object-05.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-object-05.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := { "a" : null }
+return jx:json-to-xml( $json )
+
+(: vim:set et sw=2 ts=2: :)

=== added file 'test/rbkt/Queries/zorba/json/json-snelson-j2x-utf8-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-j2x-utf8-01.xq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-j2x-utf8-01.xq	2013-07-26 23:55:36 +0000
@@ -0,0 +1,6 @@
+(: Try parsing a UTF-8 value :)
+
+import module namespace jx = "http://zorba.io/modules/json-xml";;
+
+let $json := { "mdash" : "–" }
+return jx:json-to-xml( $json )

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '[ true ]'
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '[ false ]'
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '[ null ]'
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '[ 1 ]'
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '[ 1, 2 ]'
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-06.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-06.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-06.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-(: parse a JSON array composed of 2 JSON objects :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml( '[ { "key1": "value1" }, { "key2": "value2" } ]' )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-(: parse an JSON array composed of 2 JSON arrays :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml( '[ [ 11, 12 ], [ 21, 22 ] ]' )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-08.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-08.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-08.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-import module namespace jx =
-  "http://zorba.io/modules/json-xml";;
-
-let $json := '[ 1, { "foo": "bar" } ]'
-return jx:json-to-xml( $json )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-empty.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-empty.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-empty.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJPE0009

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-(: try parsing an empty value :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml( <a/> )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '
-  {
-    "firstName": "John",
-    "lastName": "Smith",
-    "address": {
-      "streetAddress": "21 2nd Street",
-      "city": "New York",
-      "state": "NY",
-      "postalCode": 10021
-    },
-    "phoneNumbers": [
-      "212 732-1234",
-      "646 123-4567"
-    ]
-  }
-  '
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
-(: jx:json-to-xml testing numbers :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml( '{
-  "decimal": 2.89,
-  "e": 2E+6,
-  "negative": -1.89
-}' )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '{ "a" : 1 }'
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := '{ "a" : 1, "b" : 2 }'
-return jx:json-to-xml( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-object-03.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-03.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-import module namespace jx =
-  "http://zorba.io/modules/json-xml";;
-
-let $json := '{ "k1" : [ { "k2" : "v2" }, null ] }'
-return jx:json-to-xml( $json )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-04.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-object-04.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-04.xq	1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
-import module namespace jx =
-  "http://zorba.io/modules/json-xml";;
-
-let $json := '
-  {
-    "key1": [ 1 ],
-    "key2": "value"
-  }
-'
-return jx:json-to-xml( $json )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-(: jx:json-to-xml testing null as a key value :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml( '{ "a" : null }' )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq	1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
-import module namespace jx="http://zorba.io/modules/json-xml";;
-
-declare variable $json-element := 
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="html" type="string">&lt;b&gt;bold&lt;/b&gt;</pair>
-</json>;
-
-jx:json-to-xml( jx:xml-to-json( $json-element ) )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-(: jx:json-to-xml with uncommon characters :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml( '{ "web-app" : "!_\"-\\?*.$+" }' )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-(: try parsing a Unicode UTF-8 value :)
-
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-jx:json-to-xml( '{ "mdash": "–" }' )

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJSE0001

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq	1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := <!--comment--> 
-return jx:xml-to-json( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <json type="object">
-    <pair name="firstName" type="string">John</pair>
-    <pair name="lastName" type="string">Smith</pair>
-    <pair name="address" type="object">
-      <pair name="streetAddress" type="string">21 2nd Street</pair>
-      <pair name="city" type="string">New York</pair>
-      <pair name="state" type="string">NY</pair>
-      <pair name="postalCode" type="number">10021</pair>
-    </pair>
-    <pair name="phoneNumbers" type="array">
-      <item type="string">212 732-1234</item>
-      <item type="string">646 123-4567</item>
-    </pair>
-  </json>
-let $options := { "json-format" : "Snelson", "whitespace" : "indent" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJSE0003

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq	1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := 
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="a" type="nothing">a</pair>
-</json>
-return jx:xml-to-json( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq	1970-01-01 00:00:00 +0000
@@ -1,20 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <json type="object">
-    <pair name="firstName" type="string">John</pair>
-    <pair name="lastName" type="string">Smith</pair>
-    <pair name="address" type="object">
-      <pair name="streetAddress" type="string">21 2nd Street</pair>
-      <pair name="city" type="string">New York</pair>
-      <pair name="state" type="string">NY</pair>
-      <pair name="postalCode" type="number">10021</pair>
-    </pair>
-    <pair name="phoneNumbers" type="array">
-      <item type="string">212 732-1234</item>
-      <item type="string">646 123-4567</item>
-    </pair>
-  </json>
-return jx:xml-to-json( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-import module namespace jx="http://zorba.io/modules/json-xml";;
-
-declare variable $json-value := '{ "key" : "value" }';
-
-jx:xml-to-json( jx:json-to-xml( $json-value ) )
-
-(: vim:se et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq	1970-01-01 00:00:00 +0000
@@ -1,21 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json :=
-  <json type="object">
-    <pair name="firstName" type="string">John</pair>
-    <pair name="lastName" type="string">Smith</pair>
-    <pair name="address" type="object">
-      <pair name="streetAddress" type="string">21 2nd Street</pair>
-      <pair name="city" type="string">New York</pair>
-      <pair name="state" type="string">NY</pair>
-      <pair name="postalCode" type="number">10021</pair>
-    </pair>
-    <pair name="phoneNumbers" type="array">
-      <item type="string">212 732-1234</item>
-      <item type="string">646 123-4567</item>
-    </pair>
-  </json>
-let $options := { "json-format" : "Snelson", "whitespace" : "some" }
-return jx:xml-to-json( $json, $options )
-
-(: vim:set et sw=2 ts=2: :)

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.spec	1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
-Error: http://zorba.io/modules/zorba-errors:ZJSE0002

=== removed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq	1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-import module namespace jx = "http://zorba.io/modules/json-xml";;
-
-let $json := 
-<json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="a">a</pair>
-</json>
-return jx:xml-to-json( $json )
-
-(: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-01.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="boolean">true</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-02.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="boolean">false</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-03.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="null"/>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-04.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-04.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="number">1</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-05.xq	2013-07-26 23:55:36 +0000
@@ -1,10 +1,10 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="number">1</item>
     <item type="number">2</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.spec' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-06.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-06.spec	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-Error: http://zorba.io/modules/zorba-errors:ZJSE0005
+Error: http://zorba.io/modules/zorba-errors:ZJSE0004

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-06.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-06.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <foo type="boolean">true</foo>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.spec' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-07.spec'
=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-07.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-07.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="boolean">foo</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.spec' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-08.spec'
=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-08.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-08.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item>false</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.spec' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-09.spec'
=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-09.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-09.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="bool">false</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.spec' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-10.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-10.spec	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-Error: http://zorba.io/modules/zorba-errors:ZJSE0007
+Error: http://zorba.io/modules/zorba-errors:ZJSE0004

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-10.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-10.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     hello
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.spec' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-11.spec'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.spec	2013-06-25 03:55:20 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-11.spec	2013-07-26 23:55:36 +0000
@@ -1,1 +1,1 @@
-Error: http://zorba.io/modules/zorba-errors:ZJSE0006
+Error: http://zorba.io/modules/zorba-errors:ZJSE0004

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-11.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-11.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
     <item type="boolean"><foo/></item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-array-12.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-array-12.xq	2013-07-26 23:55:36 +0000
@@ -1,12 +1,10 @@
-(: valid json generation: comments should be ignored :)
-
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="array">
-    <!--comment-->
+    <!-- This should be ignored -->
     <item type="boolean">true</item>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-object-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-object-01.xq	2013-07-26 23:55:36 +0000
@@ -1,9 +1,9 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="object">
     <pair name="a" type="number">1</pair>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-object-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-object-02.xq	2013-07-26 23:55:36 +0000
@@ -1,10 +1,10 @@
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="object">
     <pair name="a" type="number">1</pair>
     <pair name="b" type="number">2</pair>
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-x2j-object-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq	2013-07-11 00:46:02 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-x2j-object-03.xq	2013-07-26 23:55:36 +0000
@@ -1,13 +1,11 @@
-(: valid json generation: comments should be ignored :)
-
 import module namespace jx = "http://zorba.io/modules/json-xml";;
 
-let $json :=
+let $xml :=
   <json type="object">
-    <!--comment-->
+    <!-- This should be ignored -->
     <pair name="a" type="number">1</pair>
-    <!--comment-->
+    <!-- This should be ignored -->
   </json>
-return jx:xml-to-json( $json )
+return jx:xml-to-json( $xml )
 
 (: vim:set et sw=2 ts=2: :)


Follow ups