Merge branch 'ecarm002/exceptions'
diff --git a/pom.xml b/pom.xml
index 7a734dc..3f1f390 100644
--- a/pom.xml
+++ b/pom.xml
@@ -575,6 +575,8 @@
                         <exclude>**/ExpectedTestResults/**</exclude>
                         <exclude>**/xqts.txt</exclude>
                         <exclude>test-suite*/**/*</exclude>
+                        <exclude>**/TestSources/**/*.json</exclude>
+                        <exclude>ClusterControllerService/**</exclude>
                     </excludes>
                 </configuration>
             </plugin>
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceSourceMapInDocExpression.java b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceSourceMapInDocExpression.java
index c3cee5e..8f241b3 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceSourceMapInDocExpression.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/compiler/rewriter/rules/ReplaceSourceMapInDocExpression.java
@@ -102,6 +102,14 @@
                     modified = true;
                 }
             }
+            docExpression = ExpressionToolbox.findFirstFunctionExpression(expression,
+                    BuiltinFunctions.JN_JSON_DOC_1.getFunctionIdentifier());
+            if (docExpression != null) {
+                AbstractFunctionCallExpression absFnCall = (AbstractFunctionCallExpression) docExpression.getValue();
+                if (updateDocExpression(opRef, absFnCall.getArguments().get(0), context)) {
+                    modified = true;
+                }
+            }
         }
         return modified;
     }
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
index 388dcf0..60d57dd 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
+++ b/vxquery-core/src/main/java/org/apache/vxquery/functions/builtin-functions.xml
@@ -323,6 +323,13 @@
         <return type="document-node()?"/>
         <runtime type="scalar" class="org.apache.vxquery.runtime.functions.node.FnDocScalarEvaluatorFactory"/>
     </function>
+    
+    <!-- jn:json-doc($uri as  xs:string?) as json-item()?  -->
+    <function name="jn:json-doc">
+        <param name="uri" type="xs:string?"/>
+        <return type="json-item()?"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.JnDocScalarEvaluatorFactory"/>
+    </function>
 
     <!-- fn:doc-available($uri  as xs:string?) as  xs:boolean -->
     <function name="fn:doc-available">
@@ -1155,6 +1162,13 @@
         <return type="xs:string*"/>
         <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.JnKeysScalarEvaluatorFactory"/>
     </function>
+    
+    <!-- jn:members($arg as item()*) as item()* -->
+    <function name="jn:members">
+        <param name="arg" type="item()*"/>
+        <return type="item()*"/>
+        <runtime type="scalar" class="org.apache.vxquery.runtime.functions.json.JnMembersScalarEvaluatorFactory"/>
+    </function>
 
     <!-- jn:null() as js:null -->
     <function name="jn:null">
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/jsonparser/JSONParser.java b/vxquery-core/src/main/java/org/apache/vxquery/jsonparser/JSONParser.java
new file mode 100644
index 0000000..9e8bffe
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/jsonparser/JSONParser.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.vxquery.jsonparser;
+
+import java.io.DataOutput;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.htrace.fasterxml.jackson.core.JsonFactory;
+import org.apache.htrace.fasterxml.jackson.core.JsonParseException;
+import org.apache.htrace.fasterxml.jackson.core.JsonParser;
+import org.apache.htrace.fasterxml.jackson.core.JsonToken;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.builders.atomic.StringValueBuilder;
+import org.apache.vxquery.datamodel.builders.jsonitem.ArrayBuilder;
+import org.apache.vxquery.datamodel.builders.jsonitem.ObjectBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.xmlparser.IParser;
+
+public class JSONParser implements IParser {
+
+    final JsonFactory factory;
+    protected final ArrayBackedValueStorage atomic;
+    protected final List<ArrayBuilder> abStack;
+    protected final List<ObjectBuilder> obStack;
+    protected final List<ArrayBackedValueStorage> abvsStack;
+    protected final List<ArrayBackedValueStorage> keyStack;
+    protected final List<UTF8StringPointable> spStack;
+    protected final StringValueBuilder svb;
+    protected final DataOutput out;
+    protected itemType checkItem, startItem;
+    protected int levelArray, levelObject;
+
+    enum itemType {
+        ARRAY,
+        OBJECT
+    }
+
+    protected final List<itemType> itemStack;
+
+    public JSONParser() throws JsonParseException {
+        factory = new JsonFactory();
+        atomic = new ArrayBackedValueStorage();
+        abStack = new ArrayList<ArrayBuilder>();
+        obStack = new ArrayList<ObjectBuilder>();
+        abvsStack = new ArrayList<ArrayBackedValueStorage>();
+        keyStack = new ArrayList<ArrayBackedValueStorage>();
+        spStack = new ArrayList<UTF8StringPointable>();
+        itemStack = new ArrayList<itemType>();
+        svb = new StringValueBuilder();
+        abvsStack.add(atomic);
+        out = abvsStack.get(abvsStack.size() - 1).getDataOutput();
+
+    }
+
+    public void parseDocument(File file, ArrayBackedValueStorage result) throws HyracksDataException {
+        try {
+            DataOutput outResult = result.getDataOutput();
+            JsonParser parser = factory.createParser(file);
+            JsonToken token = parser.nextToken();
+            checkItem = null;
+            startItem = null;
+            levelArray = 0;
+            levelObject = 0;
+            while (token != null) {
+                if (itemStack.size() > 1) {
+                    checkItem = itemStack.get(itemStack.size() - 2);
+                }
+                switch (token) {
+                    case START_ARRAY:
+                        levelArray++;
+                        if (levelArray > abStack.size()) {
+                            abStack.add(new ArrayBuilder());
+                        }
+                        if (levelArray + levelObject > abvsStack.size() - 1) {
+                            abvsStack.add(new ArrayBackedValueStorage());
+                        }
+                        itemStack.add(itemType.ARRAY);
+                        abvsStack.get(levelArray + levelObject).reset();
+                        abStack.get(levelArray - 1).reset(abvsStack.get(levelArray + levelObject));
+                        break;
+                    case START_OBJECT:
+                        levelObject++;
+                        if (levelObject > obStack.size()) {
+                            obStack.add(new ObjectBuilder());
+                        }
+                        if (levelArray + levelObject > abvsStack.size() - 1) {
+                            abvsStack.add(new ArrayBackedValueStorage());
+                        }
+                        itemStack.add(itemType.OBJECT);
+                        abvsStack.get(levelArray + levelObject).reset();
+                        obStack.get(levelObject - 1).reset(abvsStack.get(levelArray + levelObject));
+                        break;
+                    case FIELD_NAME:
+                        if (levelObject > spStack.size()) {
+                            keyStack.add(new ArrayBackedValueStorage());
+                            spStack.add(new UTF8StringPointable());
+                        }
+                        keyStack.get(levelObject - 1).reset();
+                        DataOutput outk = keyStack.get(levelObject - 1).getDataOutput();
+                        svb.write(parser.getText(), outk);
+                        spStack.get(levelObject - 1).set(keyStack.get(levelObject - 1));
+                        break;
+                    case VALUE_NUMBER_INT:
+                        atomicValues(ValueTag.XS_INTEGER_TAG, parser, out, svb, levelArray, levelObject);
+                        break;
+                    case VALUE_STRING:
+                        atomicValues(ValueTag.XS_STRING_TAG, parser, out, svb, levelArray, levelObject);
+                        break;
+                    case VALUE_NUMBER_FLOAT:
+                        atomicValues(ValueTag.XS_DOUBLE_TAG, parser, out, svb, levelArray, levelObject);
+                        break;
+                    case END_ARRAY:
+                        abStack.get(levelArray - 1).finish();
+                        if (itemStack.size() > 1) {
+                            if (checkItem == itemType.ARRAY) {
+                                abStack.get(levelArray - 2).addItem(abvsStack.get(levelArray + levelObject));
+                            } else if (checkItem == itemType.OBJECT) {
+                                obStack.get(levelObject - 1).addItem(spStack.get(levelObject - 1),
+                                        abvsStack.get(levelArray + levelObject));
+                            }
+                        }
+                        itemStack.remove(itemStack.size() - 1);
+                        startItem = itemType.ARRAY;
+                        levelArray--;
+                        break;
+                    case END_OBJECT:
+                        obStack.get(levelObject - 1).finish();
+                        if (itemStack.size() > 1) {
+                            if (checkItem == itemType.OBJECT) {
+                                obStack.get(levelObject - 2).addItem(spStack.get(levelObject - 2),
+                                        abvsStack.get(levelArray + levelObject));
+                            } else if (checkItem == itemType.ARRAY) {
+                                abStack.get(levelArray - 1).addItem(abvsStack.get(levelArray + levelObject));
+                            }
+                        }
+                        itemStack.remove(itemStack.size() - 1);
+                        startItem = itemType.OBJECT;
+                        levelObject--;
+                        break;
+                    default:
+                        break;
+                }
+                token = parser.nextToken();
+            }
+            if (startItem == itemType.ARRAY || startItem == itemType.OBJECT) {
+                outResult.write(abvsStack.get(1).getByteArray());
+            } else {
+                //the atomic value is always set to be at the bottom of the arraybackedvaluestorage stack.
+                outResult.write(abvsStack.get(0).getByteArray());
+            }
+        } catch (Exception e) {
+            throw new HyracksDataException(e.toString());
+        }
+    }
+
+    public void atomicValues(int tag, JsonParser parser, DataOutput out, StringValueBuilder svb, int levelArray,
+            int levelObject) throws IOException {
+        abvsStack.get(0).reset();
+        out.write(tag);
+        if (tag == ValueTag.XS_DOUBLE_TAG) {
+            out.writeDouble(parser.getDoubleValue());
+        } else if (tag == ValueTag.XS_STRING_TAG) {
+            svb.write(parser.getText(), out);
+        } else if (tag == ValueTag.XS_INTEGER_TAG) {
+            out.writeLong(parser.getLongValue());
+        }
+        if (itemStack.size() != 0) {
+            if (itemStack.get(itemStack.size() - 1) == itemType.ARRAY) {
+                abStack.get(levelArray - 1).addItem(abvsStack.get(0));
+            } else if (itemStack.get(itemStack.size() - 1) == itemType.OBJECT) {
+                obStack.get(levelObject - 1).addItem(spStack.get(levelObject - 1), abvsStack.get(0));
+            }
+        }
+    }
+
+    @Override
+    public void parseHDFSDocument(InputStream in, ArrayBackedValueStorage abvs) throws HyracksDataException {
+
+    }
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/index/IndexConstructorUtil.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/index/IndexConstructorUtil.java
index ed409f1..0d1dbf8 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/index/IndexConstructorUtil.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/index/IndexConstructorUtil.java
@@ -36,6 +36,7 @@
 import org.apache.vxquery.runtime.functions.index.updateIndex.MetaFileUtil;
 import org.apache.vxquery.runtime.functions.index.updateIndex.XmlMetadata;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+import org.apache.vxquery.xmlparser.IParser;
 import org.apache.vxquery.xmlparser.ITreeNodeIdProvider;
 import org.apache.vxquery.xmlparser.XMLParser;
 
@@ -185,7 +186,7 @@
             throws IOException {
 
         //Get the document node
-        XMLParser parser = new XMLParser(false, nodeIdProvider, nodeId);
+        IParser parser = new XMLParser(false, nodeIdProvider, nodeId);
         FunctionHelper.readInDocFromString(file.getPath(), bbis, di, abvsFileNode, parser);
 
         nodep.set(abvsFileNode.getByteArray(), abvsFileNode.getStartOffset(), abvsFileNode.getLength());
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnDocScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnDocScalarEvaluatorFactory.java
new file mode 100644
index 0000000..827686f
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnDocScalarEvaluatorFactory.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.vxquery.runtime.functions.json;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.jsonparser.JSONParser;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+import org.apache.vxquery.xmlparser.IParser;
+
+public class JnDocScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public JnDocScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+            throws AlgebricksException {
+        final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
+        final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
+        final ByteBufferInputStream bbis = new ByteBufferInputStream();
+        final DataInputStream di = new DataInputStream(bbis);
+
+        return new AbstractTaggedValueArgumentScalarEvaluator(args) {
+
+            @Override
+            protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+                TaggedValuePointable tvp = args[0];
+                if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
+                    throw new SystemException(ErrorCode.FORG0006);
+                }
+                tvp.getValue(stringp);
+                try {
+                    IParser parser = new JSONParser();
+                    FunctionHelper.readInDocFromPointable(stringp, bbis, di, abvs, parser);
+                } catch (IOException e) {
+                    throw new SystemException(ErrorCode.FODC0002, e);
+                }
+                result.set(abvs);
+            }
+
+        };
+    }
+
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnMembersScalarEvaluator.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnMembersScalarEvaluator.java
new file mode 100644
index 0000000..5777cbc
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnMembersScalarEvaluator.java
@@ -0,0 +1,101 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+*/
+package org.apache.vxquery.runtime.functions.json;
+
+import java.io.IOException;
+
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.accessors.SequencePointable;
+import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
+import org.apache.vxquery.datamodel.accessors.jsonitem.ArrayPointable;
+import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
+import org.apache.vxquery.datamodel.values.ValueTag;
+import org.apache.vxquery.datamodel.values.XDMConstants;
+import org.apache.vxquery.exceptions.ErrorCode;
+import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
+
+public class JnMembersScalarEvaluator extends AbstractTaggedValueArgumentScalarEvaluator {
+    protected final IHyracksTaskContext ctx;
+    private final SequencePointable sp1, sp2;
+    private final ArrayBackedValueStorage abvs;
+    private final SequenceBuilder sb;
+    private ArrayPointable ap;
+
+    public JnMembersScalarEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args) {
+        super(args);
+        this.ctx = ctx;
+        sp1 = (SequencePointable) SequencePointable.FACTORY.createPointable();
+        sp2 = (SequencePointable) SequencePointable.FACTORY.createPointable();
+        abvs = new ArrayBackedValueStorage();
+        sb = new SequenceBuilder();
+        ap = (ArrayPointable) ArrayPointable.FACTORY.createPointable();
+    }
+
+    @Override
+    protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
+        TaggedValuePointable tvp = args[0];
+        TaggedValuePointable tvp1 = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
+        abvs.reset();
+        sb.reset(abvs);
+        if (tvp.getTag() == ValueTag.SEQUENCE_TAG) {
+            TaggedValuePointable tempTvp = ppool.takeOne(TaggedValuePointable.class);
+            try {
+                tvp.getValue(sp1);
+                int size1 = sp1.getEntryCount();
+                for (int i = 0; i < size1; i++) {
+                    sp1.getEntry(i, tempTvp);
+                    if (tempTvp.getTag() == ValueTag.ARRAY_TAG) {
+                        membersSequence(tempTvp, result, tvp1);
+                    } else {
+                        XDMConstants.setEmptySequence(result);
+                    }
+                }
+            } finally {
+                ppool.giveBack(tempTvp);
+            }
+        } else if (tvp.getTag() == ValueTag.ARRAY_TAG) {
+            membersSequence(tvp, result, tvp1);
+        } else {
+            XDMConstants.setEmptySequence(result);
+        }
+        try {
+            sb.finish();
+            result.set(abvs);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void membersSequence(TaggedValuePointable tvp, IPointable result, TaggedValuePointable tvp1)
+            throws SystemException {
+        tvp.getValue(ap);
+        tvp.getValue(sp2);
+        int size = sp2.getEntryCount();
+        for (int j = 0; j < size; j++) {
+            sp2.getEntry(j, tvp1);
+            try {
+                sb.addItem(tvp1);
+            } catch (IOException e) {
+                throw new SystemException(ErrorCode.SYSE0001, e);
+            }
+        }
+    }
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnMembersScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnMembersScalarEvaluatorFactory.java
new file mode 100644
index 0000000..59a923d
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/json/JnMembersScalarEvaluatorFactory.java
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+*/
+package org.apache.vxquery.runtime.functions.json;
+
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
+
+public class JnMembersScalarEvaluatorFactory extends AbstractTaggedValueArgumentScalarEvaluatorFactory {
+
+    private static final long serialVersionUID = 1L;
+
+    public JnMembersScalarEvaluatorFactory(IScalarEvaluatorFactory[] args) {
+        super(args);
+    }
+
+    @Override
+    protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
+            throws AlgebricksException {
+        return new JnMembersScalarEvaluator(ctx, args);
+    }
+
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocAvailableScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocAvailableScalarEvaluatorFactory.java
index 8820234..d4d305d 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocAvailableScalarEvaluatorFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocAvailableScalarEvaluatorFactory.java
@@ -27,6 +27,7 @@
 import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
 import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+import org.apache.vxquery.xmlparser.IParser;
 import org.apache.vxquery.xmlparser.ITreeNodeIdProvider;
 import org.apache.vxquery.xmlparser.TreeNodeIdProvider;
 import org.apache.vxquery.xmlparser.XMLParser;
@@ -77,7 +78,7 @@
                 }
                 tvp.getValue(stringp);
                 try {
-                    XMLParser parser = new XMLParser(false, nodeIdProvider, nodeId);
+                    IParser parser = new XMLParser(false, nodeIdProvider, nodeId);
                     FunctionHelper.readInDocFromPointable(stringp, bbis, di, abvs, parser);
                     XDMConstants.setTrue(result);
                 } catch (Exception e) {
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocScalarEvaluatorFactory.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocScalarEvaluatorFactory.java
index 038a185..ecc8421 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocScalarEvaluatorFactory.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/node/FnDocScalarEvaluatorFactory.java
@@ -27,6 +27,7 @@
 import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluator;
 import org.apache.vxquery.runtime.functions.base.AbstractTaggedValueArgumentScalarEvaluatorFactory;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
+import org.apache.vxquery.xmlparser.IParser;
 import org.apache.vxquery.xmlparser.ITreeNodeIdProvider;
 import org.apache.vxquery.xmlparser.TreeNodeIdProvider;
 import org.apache.vxquery.xmlparser.XMLParser;
@@ -78,7 +79,7 @@
                 tvp.getValue(stringp);
                 try {
                     // Only one document should be parsed so its ok to have a unique parser.
-                    XMLParser parser = new XMLParser(false, nodeIdProvider, nodeId);
+                    IParser parser = new XMLParser(false, nodeIdProvider, nodeId);
                     FunctionHelper.readInDocFromPointable(stringp, bbis, di, abvs, parser);
                 } catch (Exception e) {
                     throw new SystemException(ErrorCode.SYSE0001, e);
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
index 5b9504e..8aa7696 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/runtime/functions/util/FunctionHelper.java
@@ -26,6 +26,7 @@
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.htrace.fasterxml.jackson.core.JsonParseException;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.DoublePointable;
@@ -51,7 +52,7 @@
 import org.apache.vxquery.runtime.functions.strings.UTF8StringCharacterIterator;
 import org.apache.vxquery.types.BuiltinTypeConstants;
 import org.apache.vxquery.types.BuiltinTypeRegistry;
-import org.apache.vxquery.xmlparser.XMLParser;
+import org.apache.vxquery.xmlparser.IParser;
 
 public class FunctionHelper {
 
@@ -482,7 +483,7 @@
 
     public static boolean compareTaggedValues(AbstractValueComparisonOperation aOp, TaggedValuePointable tvp1,
             TaggedValuePointable tvp2, DynamicContext dCtx, TypedPointables tp1, TypedPointables tp2)
-            throws SystemException {
+                    throws SystemException {
         int tid1 = getBaseTypeForComparisons(tvp1.getTag());
         int tid2 = getBaseTypeForComparisons(tvp2.getTag());
 
@@ -1217,7 +1218,8 @@
     }
 
     public static void readInDocFromPointable(UTF8StringPointable stringp, ByteBufferInputStream bbis,
-            DataInputStream di, ArrayBackedValueStorage abvs, XMLParser parser) throws HyracksDataException {
+            DataInputStream di, ArrayBackedValueStorage abvs, IParser parser)
+                    throws NumberFormatException, JsonParseException, IOException {
         String fName;
         try {
             fName = getStringFromPointable(stringp, bbis, di);
@@ -1228,7 +1230,8 @@
     }
 
     public static void readInDocFromString(String fName, ByteBufferInputStream bbis, DataInputStream di,
-            ArrayBackedValueStorage abvs, XMLParser parser) throws HyracksDataException {
+            ArrayBackedValueStorage abvs, IParser parser)
+                    throws NumberFormatException, JsonParseException, IOException {
         if (!fName.contains("hdfs:/")) {
             File file = new File(fName);
             if (file.exists()) {
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IParser.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IParser.java
new file mode 100644
index 0000000..7397f03
--- /dev/null
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/IParser.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.vxquery.xmlparser;
+
+import java.io.File;
+import java.io.InputStream;
+
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+
+public interface IParser {
+    public void parseDocument(File file, ArrayBackedValueStorage abvs) throws HyracksDataException;
+
+    public void parseHDFSDocument(InputStream in, ArrayBackedValueStorage abvs) throws HyracksDataException;
+}
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
index 34d7ba9..d11e1c1 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlparser/XMLParser.java
@@ -39,7 +39,7 @@
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderFactory;
 
-public class XMLParser {
+public class XMLParser implements IParser {
     final XMLReader parser;
     final SAXContentHandler handler;
     final InputSource in;
@@ -128,7 +128,7 @@
     }
 
     public void parseHDFSElements(InputStream inputStream, IFrameWriter writer, FrameTupleAccessor fta, int tupleIndex)
-            throws IOException {
+            throws HyracksDataException {
         try {
             Reader input;
             if (bufferSize > 0) {
@@ -140,13 +140,10 @@
             handler.setupElementWriter(writer, tupleIndex);
             parser.parse(in);
             input.close();
-        } catch (IOException e) {
+        } catch (Exception e) {
             HyracksDataException hde = new HyracksDataException(e);
             hde.setNodeId(nodeId);
             throw hde;
-        } catch (SAXException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
         }
     }
 
@@ -162,13 +159,10 @@
             parser.parse(in);
             handler.writeDocument(abvs);
             input.close();
-        } catch (IOException e) {
+        } catch (Exception e) {
             HyracksDataException hde = new HyracksDataException(e);
             hde.setNodeId(nodeId);
             throw hde;
-        } catch (SAXException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
         }
     }
 }
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members1.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members1.txt
new file mode 100644
index 0000000..012b0cf
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members1.txt
@@ -0,0 +1,7 @@
+mercury
+venus
+earth
+mars
+1
+2
+3
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members2.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members2.txt
new file mode 100644
index 0000000..7a754f4
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members2.txt
@@ -0,0 +1,2 @@
+1
+2
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members3.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members3.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Functions/jn_members3.txt
@@ -0,0 +1 @@
+
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q01_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q01_parser.txt
new file mode 100644
index 0000000..6ed63af
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q01_parser.txt
@@ -0,0 +1 @@
+[1,2]
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q02_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q02_parser.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q02_parser.txt
@@ -0,0 +1 @@
+1
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q03_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q03_parser.txt
new file mode 100644
index 0000000..5625e59
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q03_parser.txt
@@ -0,0 +1 @@
+1.2
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q04_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q04_parser.txt
new file mode 100644
index 0000000..ec186f1
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q04_parser.txt
@@ -0,0 +1 @@
+string
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q05_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q05_parser.txt
new file mode 100644
index 0000000..0c9a608
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q05_parser.txt
@@ -0,0 +1 @@
+[1,[2]]
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q06_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q06_parser.txt
new file mode 100644
index 0000000..4132caf
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q06_parser.txt
@@ -0,0 +1 @@
+{"age":23}
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q07_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q07_parser.txt
new file mode 100644
index 0000000..af1fb05
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q07_parser.txt
@@ -0,0 +1 @@
+{"employee":{"id":1}}
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q08_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q08_parser.txt
new file mode 100644
index 0000000..295244a
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q08_parser.txt
@@ -0,0 +1 @@
+[{"1":{"2":[3,{"4":5}]}},1]
diff --git a/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q09_parser.txt b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q09_parser.txt
new file mode 100644
index 0000000..a98cd71
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/ExpectedTestResults/Json/Parser/q09_parser.txt
@@ -0,0 +1 @@
+[{"1a":{"2a":[3,{"4a":5}]}},1,{"1b":{"2b":[3,{"4b":5}]}},{"1c":{"2c":[3,{"4c":5}]}}]
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members1.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members1.xq
new file mode 100644
index 0000000..0be505c
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members1.xq
@@ -0,0 +1,22 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: JSONiq jn:members :)
+(
+     let $planets :=("foo",{"foo":"bar"},["mercury","venus","earth","mars"],[1,2,3])
+          return jn:members($planets)
+)
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members2.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members2.xq
new file mode 100644
index 0000000..adaadfb
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members2.xq
@@ -0,0 +1,22 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: JSONiq jn:members :)
+(
+     let $planets :=[1,2]
+          return jn:members($planets)
+)
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members3.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members3.xq
new file mode 100644
index 0000000..e643d8d
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Functions/jn_members3.xq
@@ -0,0 +1,22 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: JSONiq jn:members :)
+(
+     let $planets := ("foo",{"foo":"bar"})
+          return jn:members($planets)
+)
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q01_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q01_parser.xq
new file mode 100644
index 0000000..4752069
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q01_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing an array :)
+    jn:json-doc("array_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q02_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q02_parser.xq
new file mode 100644
index 0000000..9d73500
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q02_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing an atomic int :)
+    jn:json-doc("int_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q03_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q03_parser.xq
new file mode 100644
index 0000000..2ba7384
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q03_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing a double :)
+    jn:json-doc("double_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q04_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q04_parser.xq
new file mode 100644
index 0000000..6f15917
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q04_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing a string :)
+    jn:json-doc("string_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q05_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q05_parser.xq
new file mode 100644
index 0000000..413df0b
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q05_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing nested arrays :)
+    jn:json-doc("nested_arrays_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q06_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q06_parser.xq
new file mode 100644
index 0000000..7e8e1b3
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q06_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing an object :)
+    jn:json-doc("object_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q07_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q07_parser.xq
new file mode 100644
index 0000000..e25ac91
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q07_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing nested object :)
+    jn:json-doc("nested_object_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q08_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q08_parser.xq
new file mode 100644
index 0000000..d60c2ce
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q08_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing nested objects and arrays :)
+    jn:json-doc("nested_object_array_json_file")
diff --git a/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q09_parser.xq b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q09_parser.xq
new file mode 100644
index 0000000..082ffc0
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/Queries/XQuery/Json/Parser/q09_parser.xq
@@ -0,0 +1,20 @@
+(: Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you 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. :)
+
+(: Json Parser Query :)
+(: parse a file containing nested objects and arrays :)
+    jn:json-doc("nested_array_object_json_file")
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/array/array.json b/vxquery-xtest/src/test/resources/TestSources/json/array/array.json
new file mode 100644
index 0000000..6ed63af
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/array/array.json
@@ -0,0 +1 @@
+[1,2]
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/array/nested_array.json b/vxquery-xtest/src/test/resources/TestSources/json/array/nested_array.json
new file mode 100644
index 0000000..0c9a608
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/array/nested_array.json
@@ -0,0 +1 @@
+[1,[2]]
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/array/nested_array_object.json b/vxquery-xtest/src/test/resources/TestSources/json/array/nested_array_object.json
new file mode 100644
index 0000000..a98cd71
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/array/nested_array_object.json
@@ -0,0 +1 @@
+[{"1a":{"2a":[3,{"4a":5}]}},1,{"1b":{"2b":[3,{"4b":5}]}},{"1c":{"2c":[3,{"4c":5}]}}]
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/atomic_double.json b/vxquery-xtest/src/test/resources/TestSources/json/atomic_double.json
new file mode 100644
index 0000000..5625e59
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/atomic_double.json
@@ -0,0 +1 @@
+1.2
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/atomic_int.json b/vxquery-xtest/src/test/resources/TestSources/json/atomic_int.json
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/atomic_int.json
@@ -0,0 +1 @@
+1
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/atomic_string.json b/vxquery-xtest/src/test/resources/TestSources/json/atomic_string.json
new file mode 100644
index 0000000..ace2d72
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/atomic_string.json
@@ -0,0 +1 @@
+"string"
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/object/nested_object.json b/vxquery-xtest/src/test/resources/TestSources/json/object/nested_object.json
new file mode 100644
index 0000000..af1fb05
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/object/nested_object.json
@@ -0,0 +1 @@
+{"employee":{"id":1}}
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/object/nested_object_array.json b/vxquery-xtest/src/test/resources/TestSources/json/object/nested_object_array.json
new file mode 100644
index 0000000..295244a
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/object/nested_object_array.json
@@ -0,0 +1 @@
+[{"1":{"2":[3,{"4":5}]}},1]
diff --git a/vxquery-xtest/src/test/resources/TestSources/json/object/object.json b/vxquery-xtest/src/test/resources/TestSources/json/object/object.json
new file mode 100644
index 0000000..4132caf
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/TestSources/json/object/object.json
@@ -0,0 +1 @@
+{"age":23}
diff --git a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
index da8b22f..8ef09a6 100644
--- a/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
+++ b/vxquery-xtest/src/test/resources/VXQueryCatalog.xml
@@ -49,6 +49,7 @@
 <!ENTITY FunctionsInJSONiq SYSTEM "cat/FunctionsInJSONiq.xml">
 <!ENTITY JsonObjectNavigationQueries SYSTEM "cat/JsonObjectNavigationQueries.xml">
 <!ENTITY JsonArrayNavigationQueries SYSTEM "cat/JsonArrayNavigationQueries.xml">
+<!ENTITY JsonParserQueries SYSTEM "cat/JsonParserQueries.xml">
 
 ]>
 <test-suite xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog"
@@ -97,6 +98,42 @@
               Creator="Shivani Mall">
          <description last-mod="2015-06-26">File</description>
       </source>
+      <source ID="array_json_file" FileName="TestSources/json/array/array.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="int_json_file" FileName="TestSources/json/atomic_int.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="double_json_file" FileName="TestSources/json/atomic_double.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="string_json_file" FileName="TestSources/json/atomic_string.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="nested_arrays_json_file" FileName="TestSources/json/array/nested_array.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="object_json_file" FileName="TestSources/json/object/object.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="nested_object_json_file" FileName="TestSources/json/object/nested_object.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="nested_object_array_json_file" FileName="TestSources/json/object/nested_object_array.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-02">File</description>
+      </source>
+      <source ID="nested_array_object_json_file" FileName="TestSources/json/array/nested_array_object.json"
+              Creator="Christina Pavlopoulou">
+         <description last-mod="2016-07-05">File</description>
+      </source>
    </sources>
    <test-group name="SingleQuery" featureOwner="Preston Carman">
       <GroupInfo>
@@ -267,6 +304,7 @@
          </GroupInfo>
          &JsonObjectNavigationQueries;
          &JsonArrayNavigationQueries;
+         &JsonParserQueries;
       </test-group>
    </test-group>
 </test-suite>
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml b/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml
index e8aface..b879332 100644
--- a/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml
+++ b/vxquery-xtest/src/test/resources/cat/FunctionsInJSONiq.xml
@@ -71,4 +71,19 @@
         <query name="jn_keys2" date="2016-06-26"/>
         <output-file compare="Text">jn_keys2.txt</output-file>
     </test-case>
+    <test-case name="functions-in-jsoniq-jn_members" FilePath="Json/Functions/" Creator="Christina Pavlopoulou">
+        <description>Query for json array members</description>
+        <query name="jn_members1" date="2016-07-05"/>
+        <output-file compare="Text">jn_members1.txt</output-file>
+    </test-case>
+    <test-case name="functions-in-jsoniq-jn_members" FilePath="Json/Functions/" Creator="Christina Pavlopoulou">
+        <description>Query for json array members</description>
+        <query name="jn_members2" date="2016-07-05"/>
+        <output-file compare="Text">jn_members2.txt</output-file>
+    </test-case>
+    <test-case name="functions-in-jsoniq-jn_members" FilePath="Json/Functions/" Creator="Christina Pavlopoulou">
+        <description>Query for json array members</description>
+        <query name="jn_members3" date="2016-07-05"/>
+        <output-file compare="Text">jn_members3.txt</output-file>
+    </test-case>
 </test-group>
\ No newline at end of file
diff --git a/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml b/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml
new file mode 100644
index 0000000..d61a1e8
--- /dev/null
+++ b/vxquery-xtest/src/test/resources/cat/JsonParserQueries.xml
@@ -0,0 +1,68 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<test-group xmlns="http://www.w3.org/2005/02/query-test-XQTSCatalog" name="JsonArrayQueries" featureOwner="VXQuery">
+   <GroupInfo>
+      <title>Json Parser</title>
+      <description/>
+   </GroupInfo>
+   <test-case name="json-parser-q01" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing json array from a file.</description>
+      <query name="q01_parser" date="2016-06-28"/>
+      <output-file compare="Text">q01_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q02" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing atomic int from json file.</description>
+      <query name="q02_parser" date="2016-06-28"/>
+      <output-file compare="Text">q02_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q03" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing atomic double from a json file.</description>
+      <query name="q03_parser" date="2016-06-28"/>
+      <output-file compare="Text">q03_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q04" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing atomic string from a json file.</description>
+      <query name="q04_parser" date="2016-06-28"/>
+      <output-file compare="Text">q04_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q05" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing nested arrays from a json file.</description>
+      <query name="q05_parser" date="2016-06-29"/>
+      <output-file compare="Text">q05_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q06" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing an object from a json file.</description>
+      <query name="q06_parser" date="2016-06-29"/>
+      <output-file compare="Text">q06_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q07" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing nested objects from a json file.</description>
+      <query name="q07_parser" date="2016-06-30"/>
+      <output-file compare="Text">q07_parser.txt</output-file>
+   </test-case>
+    <test-case name="json-parser-q08" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing nested objects and arrays from a json file.</description>
+      <query name="q08_parser" date="2016-06-30"/>
+      <output-file compare="Text">q08_parser.txt</output-file>
+   </test-case>
+   <test-case name="json-parser-q09" FilePath="Json/Parser/" Creator="Christina Pavlopoulou">
+      <description>Parsing nested objects and arrays from a json file.</description>
+      <query name="q09_parser" date="2016-07-05"/>
+      <output-file compare="Text">q09_parser.txt</output-file>
+   </test-case>
+</test-group>
diff --git a/vxquery-xtest/src/test/resources/cat/SingleQuery.xml b/vxquery-xtest/src/test/resources/cat/SingleQuery.xml
index add4fab..c9bd305 100644
--- a/vxquery-xtest/src/test/resources/cat/SingleQuery.xml
+++ b/vxquery-xtest/src/test/resources/cat/SingleQuery.xml
@@ -23,4 +23,9 @@
       <query name="add" date="2014-08-18"/>
       <output-file compare="Text">add.txt</output-file>
    </test-case>
-</test-group>
\ No newline at end of file
+   <test-case name="simple-fn-doc" FilePath="Simple/" Creator="Preston Carman">
+      <description>Adds two numbers.</description>
+      <query name="fn_doc" date="2014-08-18"/>
+      <output-file compare="Text">fn_doc.txt</output-file>
+   </test-case>
+</test-group>