← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/feature-json_strip_array into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/feature-json_strip_array into lp:zorba.

Commit message:
Added ability to strip the top-level array from a JSON stream.

Requested reviews:
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/feature-json_strip_array/+merge/136826

Added ability to strip the top-level array from a JSON stream.
-- 
https://code.launchpad.net/~paul-lucas/zorba/feature-json_strip_array/+merge/136826
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'modules/org/jsoniq/www/functions.xq'
--- modules/org/jsoniq/www/functions.xq	2012-10-08 12:09:36 +0000
+++ modules/org/jsoniq/www/functions.xq	2012-11-29 01:19:22 +0000
@@ -170,6 +170,7 @@
  : Allowed options are
  : <ul>
  :   <li>jsoniq-multiple-top-level-items: allow parsing of sequences of JSON Objects and Arrays (boolean; default: true)</li>
+ :   <li>jsoniq-strip-top-level-array: if the top-level JSON item is an array, strip it and return its elements as multiple top-level items (boolean; default: false)</li>
  : </ul>
  :
  : @error jerr:JNDY0021 if the given string is not valid JSON or

=== modified file 'src/compiler/parser/query_loc.h'
--- src/compiler/parser/query_loc.h	2012-09-19 21:16:15 +0000
+++ src/compiler/parser/query_loc.h	2012-11-29 01:19:22 +0000
@@ -17,9 +17,9 @@
 #ifndef ZORBA_QUERY_LOC_H
 #define ZORBA_QUERY_LOC_H
 
+#include <zorba/internal/ztd.h>
 #include "zorbatypes/zstring.h"
 
-
 namespace zorba {
 
 namespace serialization
@@ -27,6 +27,8 @@
   class Archiver;
 }
 
+///////////////////////////////////////////////////////////////////////////////
+
 /**
  * Class to save the query location of zorba elements that correspond to a code
  * snipped in the query.
@@ -36,6 +38,7 @@
  */
 class QueryLoc 
 {
+  typedef zorba::internal::ztd::explicit_bool explicit_bool;
 public:
   static QueryLoc null;
 
@@ -79,21 +82,30 @@
  
   bool equals(const QueryLoc& loc) const;
 
-  bool operator==(const QueryLoc& loc) const
-  {
-    return equals(loc);    
-  }
-  
-  bool operator<(const QueryLoc& loc) const
-  {
-    return theLineBegin < loc.getLineBegin();
+  operator explicit_bool::type() const {
+    return explicit_bool::value_of( !equals( null ) );
   }
 };
 
+inline bool operator==( QueryLoc const &q1, QueryLoc const &q2 ) {
+  return q1.equals( q2 );
+}
+
+inline bool operator!=( QueryLoc const &q1, QueryLoc const &q2 ) {
+  return !(q1 == q2);
+}
+
+inline bool operator<( QueryLoc const &q1, QueryLoc const &q2 ) {
+  return q1.getLineBegin()  <  q2.getLineBegin()
+      || (q1.getLineBegin() == q2.getLineBegin()
+          && q1.getColumnBegin() < q2.getColumnBegin());
+}
 
 std::ostream& operator<< (std::ostream& aOstr, const QueryLoc& aQueryLoc);
 
+///////////////////////////////////////////////////////////////////////////////
+
 } // namespace zorba
 
-#endif
+#endif /* ZORBA_QUERY_LOC_H */
 /* vim:set et sw=2 ts=2: */

=== modified file 'src/runtime/CMakeLists.txt'
--- src/runtime/CMakeLists.txt	2012-10-16 14:30:02 +0000
+++ src/runtime/CMakeLists.txt	2012-11-29 01:19:22 +0000
@@ -175,6 +175,7 @@
 IF (ZORBA_WITH_JSON)
   LIST(APPEND RUNTIME_SRCS
     json/json_constructors.cpp
+    json/json_loader.cpp
   )
   HEADER_GROUP_SUBFOLDER(RUNTIME_SRCS json)
 ENDIF (ZORBA_WITH_JSON)

=== modified file 'src/runtime/json/json_impl.cpp'
--- src/runtime/json/json_impl.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/json/json_impl.cpp	2012-11-29 01:19:22 +0000
@@ -24,6 +24,7 @@
 #include "store/api/item_factory.h"
 #include "system/globalenv.h"
 
+#include "util/ascii_util.h"
 #include "util/mem_streambuf.h"
 #include "util/string_util.h"
 
@@ -103,11 +104,17 @@
       ZORBA_ASSERT( false );
   }
   catch ( json::illegal_character const &e ) {
+    char const c = e.get_char();
+    string c_as_string;
+    if ( ascii::is_print( c ) )
+      c_as_string = c;
+    else
+      c_as_string = BUILD_STRING(
+        "#x" << uppercase << hex << (static_cast<unsigned>( c ) & 0xFF)
+      );
     throw XQUERY_EXCEPTION(
       zerr::ZJPE0001_ILLEGAL_CHARACTER,
-      ERROR_PARAMS(zstring("#x") + 
-      BUILD_STRING(std::uppercase << std::hex
-                   << (static_cast<unsigned int>(e.get_char()) & 0xFF)) ),
+      ERROR_PARAMS( c_as_string ),
       ERROR_LOC( e.get_loc() )
     );
   }

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2012-11-07 17:48:17 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2012-11-29 01:19:22 +0000
@@ -55,10 +55,14 @@
 #include <store/api/store.h>
 #include <store/api/copymode.h>
 
-#include <util/uri_util.h>
+#include "util/uri_util.h"
+#include "util/json_parser.h"
+
 #include <zorba/store_consts.h>
 #include <zorbatypes/URI.h>
 
+#include "json_loader.h"
+
 
 namespace zorba {
 
@@ -744,51 +748,59 @@
 {
   PlanIteratorState::init(aState);
   theAllowMultiple = true; // default
-  theInputStream = 0;
+  theInputStream = nullptr;
   theGotOne = false;
+  loader_ = nullptr;
 }
 
 void
 JSONParseIteratorState::reset(PlanState& aState)
 {
   PlanIteratorState::reset(aState);
-  if (theInput == NULL && theInputStream)
-  {
+  if (theInput == NULL) {
     delete theInputStream;
+    theInputStream = nullptr;
   }
+  theGotOne = false;
+  delete loader_;
+  loader_ = nullptr;
 }
 
 JSONParseIteratorState::~JSONParseIteratorState()
 {
-  if (theInput == NULL && theInputStream)
-  {
+  if (theInput == NULL)
     delete theInputStream;
-  }
+  delete loader_;
 }
 
-void
-JSONParseIterator::processOptions(
-    const store::Item_t& aOptions,
-    bool& aAllowMultiple) const
+bool JSONParseIterator::processBooleanOption( store::Item_t const &options,
+                                              char const *option_name,
+                                              bool *option_value ) const
 {
-  store::Item_t lOptionName, lOptionValue;
-
-  zstring s("jsoniq-multiple-top-level-items");
-  GENV_ITEMFACTORY->createString(lOptionName, s);
-  lOptionValue = aOptions->getObjectValue(lOptionName);
-
-  if (lOptionValue != NULL)
-  {
-    store::SchemaTypeCode lType = lOptionValue->getTypeCode();
-    if (!TypeOps::is_subtype(lType, store::XS_BOOLEAN))
-    {
-      const TypeManager* tm = theSctx->get_typemanager();
-      xqtref_t lType = tm->create_value_type(lOptionValue, loc);
-      RAISE_ERROR(jerr::JNTY0020, loc,
-      ERROR_PARAMS(lType->toSchemaString(), s, "xs:boolean"));
+  store::Item_t i_option_name;
+  zstring z_option_name( option_name );
+  GENV_ITEMFACTORY->createString( i_option_name, z_option_name );
+  store::Item_t i_option_value = options->getObjectValue( i_option_name );
+
+  if ( i_option_value ) {
+    store::SchemaTypeCode const option_type = i_option_value->getTypeCode();
+    if ( !TypeOps::is_subtype( option_type, store::XS_BOOLEAN ) ) {
+      TypeManager const *const tm = theSctx->get_typemanager();
+      xqtref_t const option_type = tm->create_value_type( i_option_value, loc );
+      throw XQUERY_EXCEPTION(
+        jerr::JNTY0020,
+        ERROR_PARAMS(
+          option_type->toSchemaString(),
+          z_option_name,
+          "xs:boolean"
+        ),
+        ERROR_LOC( loc )
+      );
     }
-    aAllowMultiple = lOptionValue->getBooleanValue();
+    *option_value = i_option_value->getBooleanValue();
+    return true;
   }
+  return false;
 }
 
 bool
@@ -797,6 +809,7 @@
   PlanState& planState) const
 {
   store::Item_t lInput;
+  bool lStripTopLevelArray = false;
 
   JSONParseIteratorState* state;
   DEFAULT_STACK_INIT(JSONParseIteratorState, state, planState);
@@ -807,7 +820,12 @@
     {
       store::Item_t lOptions;
       consumeNext(lOptions, theChildren[1].getp(), planState);
-      processOptions(lOptions, state->theAllowMultiple);
+      processBooleanOption(
+        lOptions, "jsoniq-multiple-top-level-items", &state->theAllowMultiple
+      );
+      processBooleanOption(
+        lOptions, "jsoniq-strip-top-level-array", &lStripTopLevelArray
+      );
     }
 
     if (lInput->isStreamable())
@@ -818,59 +836,35 @@
     else
     {
       // will be deleted in the state
-      state->theInputStream = new std::stringstream(
-          lInput->getStringValue().c_str());
-    }
-
-    while (true)
-    {
-      try
-      {
-        // streamable string or non-literal string
-        if (state->theInput != NULL || theRelativeLocation == QueryLoc::null)
-        {
-          result = GENV_STORE.parseJSON(*state->theInputStream, 0);
-        }
-        else
-        {
-          // pass the query location of the StringLiteral to the JSON
-          // parser such that it can give better error locations.
-          zorba::internal::diagnostic::location lLoc;
-          lLoc = ERROR_LOC(theRelativeLocation);
-          result = GENV_STORE.parseJSON(*state->theInputStream, &lLoc);
-        }
-      }
-      catch (zorba::XQueryException& e)
-      {
-        // rethrow with JNDY0021
-        XQueryException xq = XQUERY_EXCEPTION(
-            jerr::JNDY0021,
-            ERROR_PARAMS(e.what()),
-            ERROR_LOC(loc));
-
-        // use location of e in case of literal string
-        if (!(theRelativeLocation == QueryLoc::null)) set_source(xq, e);
-        throw xq;
-      }
-
-      if (result != NULL)
-      {
-        if (!state->theAllowMultiple && state->theGotOne)
-        {
-          RAISE_ERROR(jerr::JNDY0021, loc,
-          ERROR_PARAMS(ZED(JSON_UNEXPECTED_EXTRA_CONTENT)));
-        }
-        state->theGotOne = true;
-        STACK_PUSH(true, state);
-        continue;
-      }
-      else
-      {
-        break;
-      }
+      state->theInputStream =
+        new std::stringstream( lInput->getStringValue().c_str() );
+    }
+
+    state->loader_ = new json::loader(
+      *state->theInputStream, lStripTopLevelArray
+    );
+
+    if ( state->theInput == NULL && theRelativeLocation ) {
+      // pass the query location of the StringLiteral to the JSON
+      // parser such that it can give better error locations.
+      state->loader_->set_loc(
+        theRelativeLocation.getFilename().c_str(),
+        theRelativeLocation.getLineBegin(),
+        theRelativeLocation.getColumnBegin()
+      );
+    }
+
+    while ( state->loader_->next( &result ) ) {
+      if ( !state->theAllowMultiple && state->theGotOne ) {
+        RAISE_ERROR(
+          jerr::JNDY0021, loc,
+          ERROR_PARAMS( ZED( JSON_UNEXPECTED_EXTRA_CONTENT ) )
+        );
+      }
+      state->theGotOne = true;
+      STACK_PUSH( true, state );
     }
   }
-
   STACK_END(state);
 }
 
@@ -1606,6 +1600,30 @@
 /*******************************************************************************
 
 ********************************************************************************/
+
+void
+JSONDocIteratorState::init(PlanState& aState)
+{
+  PlanIteratorState::init(aState);
+  theStream = nullptr;
+  theGotOne = false;
+  loader_ = nullptr;
+}
+
+void
+JSONDocIteratorState::reset(PlanState& aState)
+{
+  PlanIteratorState::reset(aState);
+  theGotOne = false;
+  delete loader_;
+  loader_ = nullptr;
+}
+
+JSONDocIteratorState::~JSONDocIteratorState()
+{
+  delete loader_;
+}
+
 bool JSONDocIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
   store::Item_t uriItem;
@@ -1646,38 +1664,19 @@
     }
 
     state->theGotOne = false;
+    state->loader_ = new json::loader( *state->theStream );
 
-    while (true)
+    while ( state->loader_->next( &result ) )
     {
-      try
-      {
-        result = GENV_STORE.parseJSON(*state->theStream, 0);
-      }
-      catch (zorba::XQueryException& e)
-      {
-        // rethrow with JNDY0021
-        XQueryException xq = XQUERY_EXCEPTION(
-            jerr::JNDY0021,
-            ERROR_PARAMS(e.what()),
-            ERROR_LOC(loc));
-
-        // use location of e in case of literal string
-        throw xq;
-      }
-      if (result != NULL)
-      {
-        if (!state->theGotOne)
-        {
-          state->theGotOne = true;
-          STACK_PUSH(true, state);
-        } else {
-          RAISE_ERROR(
-              jerr::JNDY0021,
-              loc,
-              ERROR_PARAMS(ZED(JSON_UNEXPECTED_EXTRA_CONTENT)));
-        }
+      if (!state->theGotOne)
+      {
+        state->theGotOne = true;
+        STACK_PUSH(true, state);
       } else {
-        break;
+        RAISE_ERROR(
+            jerr::JNDY0021,
+            loc,
+            ERROR_PARAMS(ZED(JSON_UNEXPECTED_EXTRA_CONTENT)));
       }
     }
   }
@@ -1686,6 +1685,6 @@
 }
 
 } /* namespace zorba */
+
+#endif /* ZORBA_WITH_JSON */
 /* vim:set et sw=2 ts=2: */
-
-#endif /* ZORBA_WITH_JSON */

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp'
--- src/runtime/json/pregenerated/jsoniq_functions.cpp	2012-10-15 13:39:36 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.cpp	2012-11-29 01:19:22 +0000
@@ -384,16 +384,6 @@
 
 JSONDocIteratorState::JSONDocIteratorState() {}
 
-JSONDocIteratorState::~JSONDocIteratorState() {}
-
-
-void JSONDocIteratorState::init(PlanState& planState) {
-  PlanIteratorState::init(planState);
-}
-
-void JSONDocIteratorState::reset(PlanState& planState) {
-  PlanIteratorState::reset(planState);
-}
 // </JSONDocIterator>
 
 

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.h'
--- src/runtime/json/pregenerated/jsoniq_functions.h	2012-10-15 13:49:05 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.h	2012-11-29 01:19:22 +0000
@@ -30,6 +30,7 @@
 #include "runtime/base/noarybase.h"
 #include "runtime/base/narybase.h"
 #include <context/uri_resolver.h>
+#include "runtime/json/json_loader.h"
 
 
 namespace zorba {
@@ -151,6 +152,7 @@
   store::Item_t theInput; //
   std::istream* theInputStream; //
   bool theGotOne; //
+  json::loader* loader_; //
 
   JSONParseIteratorState();
 
@@ -185,7 +187,7 @@
   virtual ~JSONParseIterator();
 
 public:
-  void processOptions(const store::Item_t& aOptions, bool& aAllowMultiple) const;
+  bool processBooleanOption(const store::Item_t& options, char const* option_name, bool* option_value) const;
   void accept(PlanIterVisitor& v) const;
 
   bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;
@@ -468,6 +470,7 @@
   std::auto_ptr<internal::Resource> theResource; //
   std::istream* theStream; //
   bool theGotOne; //
+  json::loader* loader_; //
 
   JSONDocIteratorState();
 

=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
--- src/runtime/spec/json/jsoniq_functions.xml	2012-10-15 13:49:05 +0000
+++ src/runtime/spec/json/jsoniq_functions.xml	2012-11-29 01:19:22 +0000
@@ -11,6 +11,7 @@
 
 <zorba:header>
   <zorba:include form="Angle-bracket">context/uri_resolver.h</zorba:include>
+  <zorba:include form="Quoted">runtime/json/json_loader.h</zorba:include>
 </zorba:header>
   
 <!--
@@ -180,6 +181,7 @@
     <zorba:member type="store::Item_t" name="theInput" brief=""/>
     <zorba:member type="std::istream*" name="theInputStream" brief=""/>
     <zorba:member type="bool" name="theGotOne"/>
+    <zorba:member type="json::loader*" name="loader_" brief=""/>
   </zorba:state>
 
   <zorba:constructor>
@@ -188,9 +190,10 @@
 
   <zorba:member type="QueryLoc" name="theRelativeLocation" />
 
-  <zorba:method return="void" name="processOptions" const="true">
-    <zorba:param type="const store::Item_t&amp;" name="aOptions"/>
-    <zorba:param type="bool&amp;" name="aAllowMultiple"/>
+  <zorba:method return="bool" name="processBooleanOption" const="true">
+    <zorba:param type="const store::Item_t&amp;" name="options"/>
+    <zorba:param type="char const*" name="option_name"/>
+    <zorba:param type="bool*" name="option_value"/>
   </zorba:method>
 
 </zorba:iterator>
@@ -403,10 +406,11 @@
     
   </zorba:function>
   
-  <zorba:state>
+  <zorba:state generateInit="false" generateReset="false" generateDestructor="false">
     <zorba:member type="std::auto_ptr&lt;internal::Resource&gt;" name="theResource" brief=""/>
     <zorba:member type="std::istream*" name="theStream" brief=""/>
     <zorba:member type="bool" name="theGotOne" brief=""/>
+    <zorba:member type="json::loader*" name="loader_" brief=""/>
   </zorba:state>
   
 </zorba:iterator>

=== modified file 'src/store/api/store.h'
--- src/store/api/store.h	2012-09-19 21:16:15 +0000
+++ src/store/api/store.h	2012-11-29 01:19:22 +0000
@@ -29,14 +29,6 @@
 namespace zorba 
 { 
 
-namespace internal 
-{
-namespace diagnostic 
-{
-  class location;
-}
-}
-
 SYNC_CODE(class Lock;)
 
 class TokenizerProvider;
@@ -368,13 +360,6 @@
   virtual TokenizerProvider const* getTokenizerProvider() const = 0;
 
 #endif /* ZORBA_NO_FULL_TEXT */
-
-#ifdef ZORBA_WITH_JSON
-  virtual Item_t parseJSON(
-      std::istream& stream,
-      internal::diagnostic::location* relative_error_loc
-    ) = 0;
-#endif
 };
 
 } // namespace store

=== modified file 'src/store/naive/CMakeLists.txt'
--- src/store/naive/CMakeLists.txt	2012-09-19 21:16:15 +0000
+++ src/store/naive/CMakeLists.txt	2012-11-29 01:19:22 +0000
@@ -60,7 +60,7 @@
 IF (ZORBA_WITH_JSON)
   LIST(APPEND ZORBA_STORE_IMPL_SRCS
     json_items.cpp
-    json_loader.cpp
   )
 ENDIF (ZORBA_WITH_JSON)
 
+# vim:set et sw=2 ts=2:

=== removed file 'src/store/naive/json_loader.cpp'
--- src/store/naive/json_loader.cpp	2012-10-08 12:09:36 +0000
+++ src/store/naive/json_loader.cpp	1970-01-01 00:00:00 +0000
@@ -1,307 +0,0 @@
-/*
- * Copyright 2006-2011 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "json_loader.h"
-#include "util/json_parser.h"
-#include "json_items.h"
-#include "simple_item_factory.h"
-#include "store_defs.h"
-#include "simple_store.h"
-#include "diagnostics/diagnostic.h"
-#include <cassert>
-#include <vector>
-
-namespace zorba
-{
-
-namespace simplestore
-{
-
-namespace json
-{
-
-
-/******************************************************************************
-
-*******************************************************************************/
-JSONLoader::JSONLoader(
-    std::istream& s,
-    internal::diagnostic::location* relative_error_loc
-  )
-  : in(s),
-    theRelativeLoc(relative_error_loc)
-{
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
-JSONLoader::~JSONLoader()
-{
-}
-
-#define RAISE_JSON_ERROR_NO_PARAM(msg) \
-  if (theRelativeLoc) \
-  { \
-    throw XQUERY_EXCEPTION( \
-        jerr::JNDY0021, \
-        ERROR_PARAMS( \
-          ZED(msg), \
-          "" \
-        ), \
-        ERROR_LOC(e.get_loc()) \
-     ); \
-  } \
-  else \
-  { \
-    throw ZORBA_EXCEPTION( \
-        jerr::JNDY0021, \
-        ERROR_PARAMS( \
-          ZED(msg), \
-          BUILD_STRING(e.get_loc().line(), ", ", e.get_loc().column()) \
-        ) \
-     ); \
-  } 
-
-#define RAISE_JSON_ERROR_WITH_PARAM(msg, param) \
-  if (theRelativeLoc) \
-  { \
-    throw XQUERY_EXCEPTION( \
-        jerr::JNDY0021, \
-        ERROR_PARAMS( \
-          ZED(msg), \
-          param,  \
-          "" \
-        ), \
-        ERROR_LOC(e.get_loc()) \
-     ); \
-  } \
-  else \
-  { \
-    throw ZORBA_EXCEPTION( \
-        jerr::JNDY0021, \
-        ERROR_PARAMS( \
-          ZED(msg), \
-          param, \
-          BUILD_STRING(e.get_loc().line(), ", ", e.get_loc().column()) \
-        ) \
-     ); \
-  } 
-
-/******************************************************************************
-
-*******************************************************************************/
-store::Item_t
-JSONLoader::next( )
-{
-  using namespace zorba::json;
-  using namespace zorba::simplestore;
-  using namespace zorba::simplestore::json;
-
-  try
-  {
-    BasicItemFactory& lFactory = GET_FACTORY();
-
-    JSONItem_t lRootItem;
-
-    // stack of objects, arrays, and object pairs
-    std::vector<store::Item_t> lStack;
-
-    parser lParser(in);
-    if (theRelativeLoc)
-    {
-      lParser.set_loc(theRelativeLoc->file(), theRelativeLoc->line(), theRelativeLoc->column()+1);
-    }
-
-    token lToken;
-
-    while (lParser.next(&lToken))
-    {
-      switch (lToken.get_type())
-      {
-        case token::begin_array:
-          lStack.push_back(new SimpleJSONArray());
-          break;
-
-        case token::begin_object:
-          lStack.push_back(new SimpleJSONObject());
-          break;
-
-        case token::end_array:
-        case token::end_object:
-          {
-            store::Item_t lItem = lStack.back();
-
-            lStack.pop_back();
-
-            if (lStack.empty())
-            {
-              lRootItem = lItem.cast<JSONItem>();
-            }
-            else
-            {
-              addValue(lStack, lItem);
-            }
-
-            break;
-          }
-        case token::name_separator:
-        case token::value_separator:
-            break;
-        case token::string:
-          {
-            store::Item_t lValue;
-            zstring s = lToken.get_value();
-            lFactory.createString(lValue, s);
-
-            addValue(lStack, lValue);
-            break;
-          }
-        case token::number:
-          {
-            store::Item_t lValue;
-            zstring s = lToken.get_value();
-            lFactory.createJSONNumber(lValue, s);
-            // todo check return type
-            addValue(lStack, lValue);
-            break;
-          }
-        case token::json_false:
-          {
-            store::Item_t lValue;
-            lFactory.createBoolean(lValue, false);
-            addValue(lStack, lValue);
-            break;
-          }
-        case token::json_true:
-          {
-            store::Item_t lValue;
-            lFactory.createBoolean(lValue, true);
-            addValue(lStack, lValue);
-            break;
-          }
-        case token::json_null:
-          {
-            store::Item_t lValue;
-            lFactory.createJSONNull(lValue);
-            addValue(lStack, lValue);
-            break;
-          }
-        default:
-          assert(false);
-      }
-    }
-    return lRootItem;
-  }
-  catch (zorba::json::unterminated_string& e)
-  {
-    RAISE_JSON_ERROR_NO_PARAM(JSON_UNTERMINATED_STRING)
-  }
-  catch (zorba::json::unexpected_token& e)
-  {
-    RAISE_JSON_ERROR_WITH_PARAM(JSON_UNEXPECTED_TOKEN, e.get_token())
-  }
-  catch (zorba::json::illegal_number& e)
-  {
-    RAISE_JSON_ERROR_NO_PARAM(JSON_ILLEGAL_NUMBER)
-  }
-  catch (zorba::json::illegal_literal& e)
-  {
-    RAISE_JSON_ERROR_NO_PARAM(JSON_ILLEGAL_LITERAL)
-  }
-  catch (zorba::json::illegal_escape& e)
-  {
-    RAISE_JSON_ERROR_WITH_PARAM(JSON_ILLEGAL_ESCAPE, e.get_escape())
-  }
-  catch (zorba::json::illegal_codepoint& e)
-  {
-    RAISE_JSON_ERROR_WITH_PARAM(JSON_ILLEGAL_CODEPOINT, e.get_codepoint())
-  }
-  catch (zorba::json::illegal_character& e)
-  {
-    RAISE_JSON_ERROR_WITH_PARAM(JSON_ILLEGAL_CHARACTER, e.get_char())
-  }
-  return NULL;
-}
-#undef RAISE_JSON_ERROR_WITH_PARAM
-#undef RAISE_JSON_ERROR_NO_PARAM
-
-void
-JSONLoader::addValue(
-  std::vector<store::Item_t>& aStack,
-  const store::Item_t& aValue)
-{
-  store::Item_t lLast = aStack.back();
-
-  JSONObject* lObject = dynamic_cast<JSONObject*>(lLast.getp());
-
-  if (lObject)
-  {
-    // if the top of the stack is an object, then
-    // the value must be a string which is the name
-    // of the object's next name/value pair
-    aStack.push_back(aValue);
-    return;
-  }
-
-  JSONArray* lArray  = dynamic_cast<JSONArray*>(lLast.getp());
-  if (lArray)
-  {
-    // if the top of the stack is an array, then
-    // the value must be appended to it
-    lArray->push_back(aValue);
-    return;
-  }
-
-  // Otherwise, the top of the stack must be a string, which means
-  // that the second-to-top must be an object awaiting a value associated with
-  // this name.
-  store::Item_t lString = aStack.back();
-  aStack.pop_back();
-  
-  lLast = aStack.back();
-
-  lObject = dynamic_cast<JSONObject*>(lLast.getp());
-
-  assert(lObject);
-  lObject->add(lString, aValue, false);
-}
-
-template<typename T> T*
-JSONLoader::cast(const JSONItem_t& j)
-{
-#ifndef NDEBUG
-  T* t = dynamic_cast<T*>(j.getp());
-  assert(t);
-#else
-  T* t = static_cast<T*>(j.getp());
-#endif
-  return t;
-}
-
-} /* namespace json */
-
-} /* namespace simplestore */
-
-} /* namespace zorba */
-
-/*
- * Local variables:
- * mode: c++
- * End:
- */
-/* vim:set et sw=2 ts=2: */
-

=== removed file 'src/store/naive/json_loader.h'
--- src/store/naive/json_loader.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/json_loader.h	1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright 2006-2011 The FLWOR Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ZORBA_SIMPLE_STORE_JSON_LOADER_H
-#define ZORBA_SIMPLE_STORE_JSON_LOADER_H
-
-#include "common/common.h"
-#include "shared_types.h"
-#include "store/api/item.h"
-
-namespace zorba
-{
-
-namespace internal 
-{
-namespace diagnostic 
-{
-  class location;
-}
-}
-
-
-namespace simplestore
-{
-
-namespace json
-{
-
-class JSONLoader
-{
-protected:
-  std::istream                   & in;
-  internal::diagnostic::location * theRelativeLoc;
-
-public:
-  JSONLoader(
-    std::istream& s,
-    internal::diagnostic::location* relative_error_loc);
-
-  ~JSONLoader();
-
-  store::Item_t
-  next( );
-
-private:
-  template<typename T>
-  static T*
-  cast(const JSONItem_t&);
-
-  void
-  addValue(std::vector<store::Item_t>&, const store::Item_t&);
-
-}; /* class JSONLoader */
-
-
-} /* namespace json */
-
-} /* namespace simplestore */
-
-} /* namespace zorba */
-
-#endif /* ZORBA_SIMPLE_STORE_JSON_LOADER_H */
-/*
- * Local variables:
- * mode: c++
- * End:
- */
-/* vim:set et sw=2 ts=2: */

=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp	2012-10-08 12:09:36 +0000
+++ src/store/naive/simple_store.cpp	2012-11-29 01:19:22 +0000
@@ -35,10 +35,6 @@
 #include <zorba/util/uuid.h>
 #include "zorbautils/string_util.h"
 
-#ifdef ZORBA_WITH_JSON
-#include "json_loader.h"
-#endif
-
 
 namespace zorba
 {
@@ -419,18 +415,5 @@
 }
 
 
-#ifdef ZORBA_WITH_JSON
-/*******************************************************************************
-
-********************************************************************************/
-store::Item_t SimpleStore::parseJSON(
-    std::istream& stream,
-    internal::diagnostic::location* relative_error_loc)
-{
-  json::JSONLoader lLoader(stream, relative_error_loc);
-  return lLoader.next();
-}
-#endif /* ZORBA_WITH_JSON */
-
 } // namespace simplestore
 } // namespace zorba

=== modified file 'src/store/naive/simple_store.h'
--- src/store/naive/simple_store.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_store.h	2012-11-29 01:19:22 +0000
@@ -113,12 +113,6 @@
   bool assignReference(const store::Item* node, const zstring& reference);
 
   bool getNodeByReference(store::Item_t& result, const zstring& reference);
-
-#ifdef ZORBA_WITH_JSON
-  store::Item_t parseJSON(
-      std::istream& stream,
-      internal::diagnostic::location* relative_error_loc);
-#endif
 };
 
 } // namespace store

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-numbers-and-decimals.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-numbers-and-decimals.xml.res	2012-01-23 23:22:52 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-numbers.xml.res	2012-11-29 01:19:22 +0000
@@ -1,7 +1,5 @@
 <json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="special-numbers" 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>
-  </pair>
+  <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>

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-null-handling.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res'
--- test/rbkt/ExpQueryResults/zorba/json/json-snelson-null-handling.xml.res	2012-01-23 23:22:52 +0000
+++ test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-object-05.xml.res	2012-11-29 01:19:22 +0000
@@ -1,3 +1,3 @@
 <json xmlns="http://john.snelson.org.uk/parsing-json-into-xquery"; type="object">
-  <pair name="web-app" type="null"/>
+  <pair name="a" type="null"/>
 </json>

=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-uncommon-chars.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-uncommon-chars.xml.res'
=== renamed file 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-utf-8.xml.res' => 'test/rbkt/ExpQueryResults/zorba/json/json-snelson-parse-utf8-01.xml.res'
=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq	2011-12-23 06:21:58 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-01.xq	2012-11-29 01:19:22 +0000
@@ -6,4 +6,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:parse( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq	2011-12-23 06:21:58 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-02.xq	2012-11-29 01:19:22 +0000
@@ -11,4 +11,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:parse( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq	2011-12-23 06:21:58 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-03.xq	2012-11-29 01:19:22 +0000
@@ -15,4 +15,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:parse( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-04.xq	2012-11-29 01:19:22 +0000
@@ -1,27 +1,30 @@
 import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";;
 
-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 $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 :=
   <options xmlns="http://www.zorba-xquery.com/modules/converters/json-options";>
     <json-format value="JsonML-array"/>
   </options>
 return json:parse( $json, $options )
+
+(: vim:se et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-05.xq	2012-11-29 01:19:22 +0000
@@ -64,3 +64,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:parse( $json, $options )
+
+(: vim:se et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq	2012-01-24 01:28:36 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-06.xq	2012-11-29 01:19:22 +0000
@@ -7,4 +7,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:parse( <a/>, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq	2011-12-23 06:21:58 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-parse-wikipedia.xq	2012-11-29 01:19:22 +0000
@@ -20,4 +20,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:parse( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq	2011-12-23 06:21:58 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-01.xq	2012-11-29 01:19:22 +0000
@@ -7,4 +7,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq	2011-12-23 06:21:58 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-02.xq	2012-11-29 01:19:22 +0000
@@ -10,4 +10,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq'
--- test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq	2011-12-23 06:21:58 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-03.xq	2012-11-29 01:19:22 +0000
@@ -7,4 +7,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified 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	2011-12-28 05:41:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-indent-wikipedia.xq	2012-11-29 01:19:22 +0000
@@ -17,4 +17,5 @@
     <whitespace value="indent"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified 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	2011-12-28 05:41:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-none-wikipedia.xq	2012-11-29 01:19:22 +0000
@@ -16,4 +16,5 @@
     <json-format value="JsonML-array"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified 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	2011-12-28 05:41:00 +0000
+++ test/rbkt/Queries/zorba/json/json-jsonml_array-serialize-some-wikipedia.xq	2012-11-29 01:19:22 +0000
@@ -17,4 +17,5 @@
     <whitespace value="some"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-01.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := '[ true ]'
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-02.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := '[ false ]'
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-03.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := '[ null ]'
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-04.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := '[ 1 ]'
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-05.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := '[ 1, 2 ]'
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq	2012-01-26 01:47:19 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-array-07.xq	2012-11-29 01:19:22 +0000
@@ -3,3 +3,5 @@
 import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";;
 
 json:parse( '[ [ 11, 12 ], [ 21, 22 ] ]' )
+
+(: vim:se et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq	2012-01-24 01:28:36 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-empty.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,6 @@
 
 import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";;
 
-json:parse(<a/>)
+json:parse( <a/> )
+
+(: vim:se et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-example.xq	2012-11-29 01:19:22 +0000
@@ -17,4 +17,5 @@
   }
   '
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-numbers-and-decimals.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-numbers-and-decimals.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-numbers.xq	2012-11-29 01:19:22 +0000
@@ -1,10 +1,11 @@
-(: json:parse testing numbers and decimals :)
+(: json:parse testing numbers :)
 
 import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";;
 
-json:parse('{ "special-numbers": {
-         "decimal": 2.89,
-         "e": 2E+6,
-         "negative": -1.89
-      }
-    }')
+json:parse( '{
+  "decimal": 2.89,
+  "e": 2E+6,
+  "negative": -1.89
+}' )
+
+(: vim:se et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-01.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := '{ "a" : 1 }'
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-02.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := '{ "a" : 1, "b" : 2 }'
 return json:parse( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-null-handling.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-null-handling.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-object-05.xq	2012-11-29 01:19:22 +0000
@@ -1,5 +1,7 @@
-(: json:parse testing null handling :)
+(: json:parse testing null as a key value :)
 
 import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";;
 
-json:parse('{ "web-app": null }')
+json:parse( '{ "a" : null }' )
+
+(: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-serialize.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,6 @@
   <pair name="html" type="string">&lt;b&gt;bold&lt;/b&gt;</pair>
 </json>;
 
-json:parse(json:serialize($json-element))
+json:parse( json:serialize( $json-element ) )
+
+(: vim:se et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-uncommon-chars.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-uncommon-chars.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-uncommon-chars.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,6 @@
 
 import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";;
 
-json:parse('{ "web-app": "!_\"-\\?*.$+" }')
+json:parse( '{ "web-app" : "!_\"-\\?*.$+" }' )
+
+(: vim:se et sw=2 ts=2: :)

=== renamed file 'test/rbkt/Queries/zorba/json/json-snelson-utf-8.xq' => 'test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-utf-8.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-parse-utf8-01.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,4 @@
 
 import module namespace json = "http://www.zorba-xquery.com/modules/converters/json";;
 
-json:parse('{"mdash": "–"}')
+json:parse( '{ "mdash": "–" }' )

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq	2012-09-19 21:16:15 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-01.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item type="boolean">true</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq	2011-12-22 04:01:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-02.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item type="boolean">false</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq	2011-12-22 04:01:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-03.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item type="null"/>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq	2011-12-22 04:01:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-04.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item type="number">1</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq	2011-12-22 04:01:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-05.xq	2012-11-29 01:19:22 +0000
@@ -6,4 +6,5 @@
     <item type="number">2</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq	2011-12-22 04:56:34 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-06.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <foo type="boolean">true</foo>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq	2011-12-22 04:56:34 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-07.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item type="boolean">foo</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq	2011-12-22 04:56:34 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-08.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item>false</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq	2011-12-22 04:56:34 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-09.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item type="bool">false</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq	2011-12-22 04:56:34 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-10.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     hello
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq	2011-12-22 04:56:34 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-11.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <item type="boolean"><foo/></item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq	2012-01-26 04:43:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-array-12.xq	2012-11-29 01:19:22 +0000
@@ -8,4 +8,5 @@
     <item type="boolean">true</item>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-comment-node.xq	2012-11-29 01:19:22 +0000
@@ -2,4 +2,5 @@
 
 let $json := <!--comment--> 
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq	2011-12-28 05:41:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-indent-example.xq	2012-11-29 01:19:22 +0000
@@ -21,4 +21,5 @@
     <whitespace value="indent"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified 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	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-invalid-value-for-attribute.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
   <pair name="a" type="nothing">a</pair>
 </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq	2011-12-28 05:41:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-none-example.xq	2012-11-29 01:19:22 +0000
@@ -16,4 +16,5 @@
     </pair>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq	2011-12-22 04:01:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-object-01.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
     <pair name="a" type="number">1</pair>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq	2011-12-22 04:01:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-object-02.xq	2012-11-29 01:19:22 +0000
@@ -6,4 +6,5 @@
     <pair name="b" type="number">2</pair>
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-object-03.xq	2012-11-29 01:19:22 +0000
@@ -4,9 +4,10 @@
 
 let $json :=
   <json type="object">
-  <!--comment-->
+    <!--comment-->
     <pair name="a" type="number">1</pair>
-  <!--comment-->
+    <!--comment-->
   </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq	2012-01-26 04:43:56 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-parse.xq	2012-11-29 01:19:22 +0000
@@ -3,3 +3,5 @@
 declare variable $json-value := '{ "key" : "value" }';
 
 json:serialize( json:parse( $json-value ) )
+
+(: vim:se et sw=2 ts=2: :)

=== modified file 'test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq'
--- test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq	2011-12-28 05:41:00 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-some-example.xq	2012-11-29 01:19:22 +0000
@@ -21,4 +21,5 @@
     <whitespace value="some"/>
   </options>
 return json:serialize( $json, $options )
+
 (: vim:set et sw=2 ts=2: :)

=== modified 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	2012-01-23 23:22:52 +0000
+++ test/rbkt/Queries/zorba/json/json-snelson-serialize-type-value-missing.xq	2012-11-29 01:19:22 +0000
@@ -5,4 +5,5 @@
   <pair name="a">a</pair>
 </json>
 return json:serialize( $json )
+
 (: vim:set et sw=2 ts=2: :)


Follow ups