You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/20 14:41:00 UTC

[sling-org-apache-sling-jcr-contentparser] 01/38: SLING-6592 move and rename to jcr/contentparser, change java package and class names accordingly

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-contentparser.git

commit b485a57111f9226affe2b7c1b9384f772cf6da2c
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Mar 14 10:41:47 2017 +0000

    SLING-6592 move and rename to jcr/contentparser, change java package and class names accordingly
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1786869 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 127 ++++++++++
 .../sling/jcr/contentparser/ContentParser.java     |  50 ++++
 .../jcr/contentparser/ContentParserFactory.java    |  59 +++++
 .../sling/jcr/contentparser/ContentType.java       |  50 ++++
 .../sling/jcr/contentparser/ParseException.java    |  42 ++++
 .../sling/jcr/contentparser/ParserOptions.java     | 116 +++++++++
 .../contentparser/impl/JcrXmlContentParser.java    | 158 ++++++++++++
 .../contentparser/impl/JcrXmlValueConverter.java   | 149 ++++++++++++
 .../jcr/contentparser/impl/JsonContentParser.java  | 138 +++++++++++
 .../sling/jcr/contentparser/impl/ParserHelper.java | 134 +++++++++++
 .../sling/jcr/contentparser/package-info.java      |  23 ++
 .../impl/JcrXmlContentParserTest.java              | 129 ++++++++++
 .../impl/JcrXmlValueConverterTest.java             | 123 ++++++++++
 .../contentparser/impl/JsonContentParserTest.java  | 153 ++++++++++++
 .../jcr/contentparser/impl/ParserHelperTest.java   | 199 ++++++++++++++++
 .../sling/jcr/contentparser/impl/TestUtils.java    |  48 ++++
 src/test/resources/content-test/content.jcr.xml    | 194 +++++++++++++++
 src/test/resources/content-test/content.json       | 264 +++++++++++++++++++++
 .../invalid-test/contentWithObjectList.json        |  14 ++
 src/test/resources/invalid-test/invalid.jcr.xml    |   1 +
 src/test/resources/invalid-test/invalid.json       |   1 +
 21 files changed, 2172 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e092a3a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>30</version>
+        <relativePath />
+    </parent>
+
+    <artifactId>org.apache.sling.jcr.contentparser</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+
+    <name>Apache Sling Content Parser</name>
+    <description>
+        Parser for JCR repository content stored in files (e.g. JSON, FileVault XML).
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/contentparser</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentparser</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                      <exclude>src/test/resources/content-test/**</exclude>
+                      <exclude>src/test/resources/invalid-test/**</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.2</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.johnzon</groupId>
+            <artifactId>johnzon-core</artifactId>
+            <version>1.0.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-json_1.0_spec</artifactId>
+            <version>1.0-alpha-1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-api</artifactId>
+            <version>2.8.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-commons</artifactId>
+            <version>2.8.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit.vault</groupId>
+            <artifactId>org.apache.jackrabbit.vault</artifactId>
+            <version>3.1.18</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>15.0</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
new file mode 100644
index 0000000..cb6d013
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParser.java
@@ -0,0 +1,50 @@
+/*
+ * 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.sling.jcr.contentparser;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+/**
+ * Parses repository content from a file.
+ * Implementations have to be thread-safe.
+ */
+public interface ContentParser {
+
+    /**
+     * Parse content file.
+     * @param file File
+     * @return Content
+     * @throws IOException When I/O error occurs.
+     * @throws ParseException When parsing error occurs.
+     */
+    Map<String,Object> parse(File file) throws IOException, ParseException;
+    
+    /**
+     * Parse content.
+     * @param is Stream with serialized content
+     * @return Content as Map
+     * @throws IOException When I/O error occurs.
+     * @throws ParseException When parsing error occurs.
+     */
+    Map<String,Object> parse(InputStream is) throws IOException, ParseException;
+
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
new file mode 100644
index 0000000..7ae64e2
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentParserFactory.java
@@ -0,0 +1,59 @@
+/*
+ * 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.sling.jcr.contentparser;
+
+import org.apache.sling.jcr.contentparser.impl.JcrXmlContentParser;
+import org.apache.sling.jcr.contentparser.impl.JsonContentParser;
+
+/**
+ * Factory for content file parsers.
+ */
+public final class ContentParserFactory {
+
+    private ContentParserFactory() {
+        // static methods only
+    }
+    
+    /**
+     * Create content parser.
+     * @param type Content type
+     * @return Content parser
+     */
+    public static ContentParser create(ContentType type) {
+        return create(type, new ParserOptions());
+    }
+    
+    /**
+     * Create content parser.
+     * @param type Content type
+     * @param options Parser options
+     * @return Content parser
+     */
+    public static ContentParser create(ContentType type, ParserOptions options) {
+        switch (type) {
+            case JSON:
+                return new JsonContentParser(options);
+            case JCR_XML:
+                return new JcrXmlContentParser(options);
+            default:
+                throw new IllegalArgumentException("Unsupported type: " + type);
+        }
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
new file mode 100644
index 0000000..167722f
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ContentType.java
@@ -0,0 +1,50 @@
+/*
+ * 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.sling.jcr.contentparser;
+
+/**
+ * Content types.
+ */
+public enum ContentType {
+
+    /**
+     * JSON content.
+     */
+    JSON("json"),
+
+    /**
+     * JCR XML content.
+     */
+    JCR_XML("jcr.xml");
+
+
+    private final String extension;
+
+    private ContentType(String extension) {
+        this.extension = extension;
+    }
+
+    /**
+     * @return Extension
+     */
+    public String getExtension() {
+        return extension;
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java b/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
new file mode 100644
index 0000000..4df0160
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ParseException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.sling.jcr.contentparser;
+
+/**
+ * Parsing exception.
+ */
+public final class ParseException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * @param message Message
+     */
+    public ParseException(String message) {
+        super(message);
+    }
+    
+    /**
+     * @param message Message
+     * @param cause Cause
+     */
+    public ParseException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
new file mode 100644
index 0000000..0911dac
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/ParserOptions.java
@@ -0,0 +1,116 @@
+/*
+ * 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.sling.jcr.contentparser;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Options for content filer parser.
+ */
+public final class ParserOptions {
+    
+    /**
+     * Default primary type.
+     */
+    public static final String DEFAULT_PRIMARY_TYPE = "nt:unstructured";
+
+    /**
+     * Default list of prefixes to remove from property names.
+     */
+    public static final Set<String> DEFAULT_REMOVE_PROPERTY_NAME_PREFIXES
+            = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("jcr:reference:", "jcr:path:")));
+    
+    private String defaultPrimaryType = DEFAULT_PRIMARY_TYPE;
+    private boolean detectCalendarValues;
+    private Set<String> ignorePropertyNames;
+    private Set<String> ignoreResourceNames;
+    private Set<String> removePropertyNamePrefixes = DEFAULT_REMOVE_PROPERTY_NAME_PREFIXES;
+    
+    /**
+     * Default "jcr:primaryType" property for resources that have no explicit value for this value.
+     * If set to null, not default type is applied.
+     * @param value Default primary type.
+     * @return this
+     */
+    public ParserOptions defaultPrimaryType(String value) {
+        this.defaultPrimaryType = value;
+        return this;
+    }
+    public String getDefaultPrimaryType() {
+        return defaultPrimaryType;
+    }
+
+    /**
+     * Some content file formats like JSON do not contain information to identify date/time values.
+     * Instead they have to be detected by heuristics by trying to parse every string value.
+     * This mode is disabled by default.
+     * @param value Activate calendar value detection
+     * @return this
+     */
+    public ParserOptions detectCalendarValues(boolean value) {
+        this.detectCalendarValues = value;
+        return this;
+    }
+    public boolean isDetectCalendarValues() {
+        return detectCalendarValues;
+    }
+
+    /**
+     * Set a list of property names that should be ignored when parsing the content file.
+     * @param value List of property names 
+     * @return this
+     */
+    public ParserOptions ignorePropertyNames(Set<String> value) {
+        this.ignorePropertyNames = value;
+        return this;
+    }
+    public Set<String> getIgnorePropertyNames() {
+        return ignorePropertyNames;
+    }
+
+    /**
+     * Set a list of resource/node names that should be ignored when parsing the content file.
+     * @param value List of resource/node names
+     * @return this
+     */
+    public ParserOptions ignoreResourceNames(Set<String> value) {
+        this.ignoreResourceNames = value;
+        return this;
+    }
+    public Set<String> getIgnoreResourceNames() {
+        return ignoreResourceNames;
+    }
+
+    /**
+     * Set a list of property name prefixes that should be removed automatically from the property name. 
+     * @param value List of property name prefixes
+     * @return this
+     */
+    public ParserOptions removePropertyNamePrefixes(Set<String> value) {
+        this.removePropertyNamePrefixes = value;
+        return this;
+    }
+    public Set<String> getRemovePropertyNamePrefixes() {
+        return removePropertyNamePrefixes;
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
new file mode 100644
index 0000000..dde8c16
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParser.java
@@ -0,0 +1,158 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Parses JCR XML files that contains content fragments.
+ * Instance of this class is thread-safe.
+ */
+public final class JcrXmlContentParser implements ContentParser {
+    
+    private final ParserHelper helper;    
+    private final SAXParserFactory saxParserFactory;
+    
+    public JcrXmlContentParser(ParserOptions options) {
+        this.helper = new ParserHelper(options);
+        saxParserFactory = SAXParserFactory.newInstance();
+        saxParserFactory.setNamespaceAware(true);
+    }
+    
+    @Override
+    public Map<String,Object> parse(File file) throws IOException, ParseException {
+        try (FileInputStream fis = new FileInputStream(file)) {
+            return parse(fis);
+        }
+    }
+    
+    @Override
+    public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
+        try {
+            XmlHandler xmlHandler = new XmlHandler();
+            SAXParser parser = saxParserFactory.newSAXParser();
+            parser.parse(is, xmlHandler);
+            if (xmlHandler.hasError()) {
+                throw xmlHandler.getError();
+            }
+            return xmlHandler.getContent();
+        }
+        catch (ParserConfigurationException | SAXException ex) {
+            throw new ParseException("Error parsing JCR XML content.", ex);
+        }
+    }
+    
+    /**
+     * Decodes element or attribute names.
+     * @param qname qname
+     * @return Decoded name
+     */
+    static String decodeName(String qname) {
+        return ISO9075.decode(qname);
+    }
+    
+    /**
+     * Parses XML stream to Map.
+     */
+    class XmlHandler extends DefaultHandler {
+        private final Map<String,Object> content = new LinkedHashMap<>();
+        private final Stack<Map<String,Object>> elements = new Stack<>();
+        private SAXParseException error;
+        
+        public Map<String,Object> getContent() {
+            return content;
+        }
+        
+        public boolean hasError() {
+            return error != null;
+        }
+        
+        public SAXParseException getError() {
+            return error;
+        }
+
+        @Override
+        public void startElement(String uri, String localName, String qName, Attributes attributes)
+                throws SAXException {
+            
+            // prepare map for element
+            Map<String,Object> element;
+            if (elements.isEmpty()) {
+                element = content;
+            }
+            else {
+                element = new HashMap<>();
+                String resourceName = decodeName(qName);
+                if (!helper.ignoreResource(resourceName)) {
+                    elements.peek().put(resourceName, element);
+                }
+            }
+            elements.push(element);
+            
+            // get attributes
+            for (int i=0; i<attributes.getLength(); i++) {
+                String propertyName = helper.cleanupPropertyName(decodeName(attributes.getQName(i)));
+                if (!helper.ignoreProperty(propertyName)) {
+                    Object value = JcrXmlValueConverter.parseValue(propertyName, attributes.getValue(i));
+                    if (value != null) {
+                        element.put(propertyName, value);
+                    }
+                }
+            }
+        }
+
+        @Override
+        public void endElement(String uri, String localName, String qName) throws SAXException {
+            Map<String,Object> element = elements.pop();
+            helper.ensureDefaultPrimaryType(element);
+        }
+
+        @Override
+        public void error(SAXParseException ex) throws SAXException {
+            this.error = ex;
+        }
+
+        @Override
+        public void fatalError(SAXParseException ex) throws SAXException {
+            this.error = ex;
+        }
+        
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverter.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverter.java
new file mode 100644
index 0000000..f4cdfc4
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverter.java
@@ -0,0 +1,149 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Calendar;
+import java.util.UUID;
+
+import javax.jcr.PropertyType;
+
+import org.apache.jackrabbit.util.ISO8601;
+import org.apache.jackrabbit.vault.util.DocViewProperty;
+
+/**
+ * Parses JCR XML files that contains content fragments.
+ */
+class JcrXmlValueConverter {
+    
+    private JcrXmlValueConverter() {
+        // static methods only
+    }
+    
+    /**
+     * Parse JSON value from XML Attribute.
+     * @param value XML attribute value
+     * @return Value object
+     */
+    public static Object parseValue(final String name, final String value) {
+        if (value == null) {
+            return null;
+        }
+        DocViewProperty prop = DocViewProperty.parse(name, value);
+        
+        // convert values
+        if (prop.isMulti) {
+            Class<?> arrayType = getType(prop.type);
+            if (arrayType == null) {
+                return null;
+            }
+            Object result = Array.newInstance(arrayType, prop.values.length);
+            for (int i=0; i<prop.values.length; i++) {
+                Array.set(result, i, convertValue(prop.values[i], prop.type, true));
+            }
+            return result;
+        }
+        else {
+            return convertValue(prop.values[0], prop.type, false);
+        }
+    }
+    
+    /**
+     * Parse value depending on type prefix.
+     * @param value Value
+     * @param type Type
+     * @param inArray Value is in array
+     * @return Value object
+     */
+    private static Object convertValue(final String value, final int type, final boolean inArray) {
+        switch (type) {
+            case PropertyType.UNDEFINED:
+            case PropertyType.STRING:
+            case PropertyType.NAME:
+            case PropertyType.PATH:
+                return value;
+            case PropertyType.BOOLEAN:
+                return Boolean.valueOf(value);
+            case PropertyType.LONG:
+                return Long.valueOf(value);
+            case PropertyType.DOUBLE:
+                return Double.valueOf(value);
+            case PropertyType.DECIMAL:
+                return new BigDecimal(value);
+            case PropertyType.DATE:
+                return ISO8601.parse(value);
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+                return UUID.fromString(value);
+            case PropertyType.URI:
+                try {
+                    return new URI(value);
+                }
+                catch (URISyntaxException ex) {
+                    throw new IllegalArgumentException("Unexpected URI syntax: " + value);
+                }
+            case PropertyType.BINARY:
+                // not supported - ignore value
+                return null;
+            default:
+                throw new IllegalArgumentException("Unexpected type: " + PropertyType.nameFromValue(type));
+            
+        }
+    }
+    
+    /**
+     * Get java type for given JCR type.
+     * @param type Type
+     * @return Type
+     */
+    private static Class<?> getType(final int type) {
+        switch (type) {
+            case PropertyType.UNDEFINED:
+            case PropertyType.STRING:
+            case PropertyType.NAME:
+            case PropertyType.PATH:
+                return String.class;
+            case PropertyType.BOOLEAN:
+                return Boolean.class;
+            case PropertyType.LONG:
+                return Long.class;
+            case PropertyType.DOUBLE:
+                return Double.class;
+            case PropertyType.DECIMAL:
+                return BigDecimal.class;
+            case PropertyType.DATE:
+                return Calendar.class;
+            case PropertyType.REFERENCE:
+            case PropertyType.WEAKREFERENCE:
+                return UUID.class;
+            case PropertyType.URI:
+                return URI.class;
+            case PropertyType.BINARY:
+                // not supported - ignore value
+                return null;
+            default:
+                throw new IllegalArgumentException("Unexpected type: " + PropertyType.nameFromValue(type));
+            
+        }
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
new file mode 100644
index 0000000..b070701
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/JsonContentParser.java
@@ -0,0 +1,138 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonNumber;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.json.JsonReaderFactory;
+import javax.json.JsonString;
+import javax.json.JsonValue;
+import javax.json.stream.JsonParsingException;
+
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
+
+/**
+ * Parses JSON files that contains content fragments.
+ * Instance of this class is thread-safe.
+ */
+public final class JsonContentParser implements ContentParser {
+    
+    private final ParserHelper helper;    
+    private final JsonReaderFactory jsonReaderFactory;
+    
+    public JsonContentParser(ParserOptions options) {
+        this.helper = new ParserHelper(options);
+        // allow comments in JSON files
+        Map<String,Object> jsonReaderFactoryConfig = new HashMap<>();
+        jsonReaderFactoryConfig.put("org.apache.johnzon.supports-comments", true);
+        jsonReaderFactory = Json.createReaderFactory(jsonReaderFactoryConfig);
+    }
+    
+    @Override
+    public Map<String,Object> parse(File file) throws IOException, ParseException {
+        try (FileInputStream fis = new FileInputStream(file)) {
+            return parse(fis);
+        }
+    }
+    
+    @Override
+    public Map<String,Object> parse(InputStream is) throws IOException, ParseException {
+        try (JsonReader reader = jsonReaderFactory.createReader(is)) {
+            return toMap(reader.readObject());
+        }
+        catch (JsonParsingException ex) {
+            throw new ParseException("Error parsing JSON content.", ex);
+        }
+    }
+    
+    private Map<String,Object> toMap(JsonObject object) {
+        Map<String,Object> map = new LinkedHashMap<>();
+        for (Map.Entry<String, JsonValue> entry : object.entrySet()) {
+            String childName = entry.getKey();
+            Object value = convertValue(entry.getValue());
+            boolean ignore = false;
+            if (value instanceof Map) {
+                ignore = helper.ignoreResource(childName);
+            }
+            else {
+                childName = helper.cleanupPropertyName(childName);
+                ignore = helper.ignoreProperty(childName);
+            }
+            if (!ignore) {
+                map.put(childName, value);
+            }
+        }
+        helper.ensureDefaultPrimaryType(map);
+        return map;
+    }
+    
+    private Object convertValue(JsonValue value) {
+        switch (value.getValueType()) {
+            case STRING:
+                String stringValue = ((JsonString)value).getString();
+                Calendar calendarValue = helper.tryParseCalendar(stringValue);
+                if (calendarValue != null) {
+                    return calendarValue;
+                }
+                else {
+                    return stringValue;
+                }
+            case NUMBER:
+                JsonNumber numberValue = (JsonNumber)value;
+                if (numberValue.isIntegral()) {
+                    return numberValue.longValue();
+                }
+                else {
+                    return numberValue.bigDecimalValue();
+                }
+            case TRUE:
+                return true;
+            case FALSE:
+                return false;
+            case NULL:
+                return null;
+            case ARRAY:
+                JsonArray arrayValue = (JsonArray)value;
+                Object[] values = new Object[arrayValue.size()];
+                for (int i=0; i<values.length; i++) {
+                    values[i] = convertValue(arrayValue.get(i));
+                }
+                return helper.convertSingleTypeArray(values);
+            case OBJECT:
+                return toMap((JsonObject)value);
+            default:
+                throw new ParseException("Unexpected JSON value type: " + value.getValueType());
+        }
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java b/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
new file mode 100644
index 0000000..160cd0e
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/impl/ParserHelper.java
@@ -0,0 +1,134 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import java.lang.reflect.Array;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
+
+/**
+ * Helper parsing logic based on parser options.
+ */
+class ParserHelper {
+
+    static final String JCR_PRIMARYTYPE = "jcr:primaryType";
+
+    static final String ECMA_DATE_FORMAT = "EEE MMM dd yyyy HH:mm:ss 'GMT'Z";
+    static final Locale DATE_FORMAT_LOCALE = Locale.US;
+
+    private final ParserOptions options;
+    private final DateFormat calendarFormat;
+
+    public ParserHelper(ParserOptions options) {
+        this.options = options;
+        if (options.isDetectCalendarValues()) {
+            this.calendarFormat = new SimpleDateFormat(ECMA_DATE_FORMAT, DATE_FORMAT_LOCALE);
+        }
+        else {
+            this.calendarFormat = null;
+        }
+    }
+
+    public void ensureDefaultPrimaryType(Map<String, Object> map) {
+        String defaultPrimaryType = options.getDefaultPrimaryType();
+        if (defaultPrimaryType != null) {
+            if (!map.containsKey(JCR_PRIMARYTYPE)) {
+                map.put(JCR_PRIMARYTYPE, defaultPrimaryType);
+            }
+        }
+    }
+
+    public Calendar tryParseCalendar(String value) {
+        if (options.isDetectCalendarValues() && !StringUtils.isBlank(value)) {
+            synchronized (calendarFormat) {
+                try {
+                    Date date = calendarFormat.parse(value);
+                    Calendar calendar = Calendar.getInstance();
+                    calendar.setTime(date);
+                    return calendar;
+                }
+                catch (java.text.ParseException ex) {
+                    // ignore
+                }
+            }
+        }
+        return null;
+    }
+    
+    public boolean ignoreProperty(String propertyName) {
+        return ignoreNames(options.getIgnorePropertyNames(), propertyName);
+    }
+    
+    public boolean ignoreResource(String resourceName) {
+        return ignoreNames(options.getIgnoreResourceNames(), resourceName);
+    }
+    
+    private boolean ignoreNames(Set<String> names, String name) {
+        return names != null && names.contains(name);
+    }
+
+    public String cleanupPropertyName(String propertyName) {
+        Set<String> prefixes = options.getRemovePropertyNamePrefixes();
+        if (prefixes != null) {
+            for (String prefix : prefixes) {
+                if (StringUtils.startsWith(propertyName, prefix)) {
+                    return StringUtils.substringAfter(propertyName, prefix);
+                  }
+            }
+        }
+        return propertyName;
+    }
+    
+    public Object convertSingleTypeArray(Object[] values) {
+        if (values.length == 0) {
+            return values;
+        }
+        Class<?> itemType = null;
+        for (Object value : values) {
+            if (value == null) {
+                throw new ParseException("Multivalue array must not contain null values.");
+            }
+            if (value instanceof Map) {
+                throw new ParseException("Multivalue array must not contain maps/objects.");
+            }
+            if (itemType == null) {
+                itemType = value.getClass();
+            }
+            else if (itemType != value.getClass()) {
+                throw new ParseException("Multivalue array must not contain values with different types "
+                        + "(" + itemType.getName() + ", " + value.getClass().getName() + ").");
+            }
+        }
+        Object convertedArray = Array.newInstance(itemType, values.length);
+        for (int i=0; i<values.length; i++) {
+            Array.set(convertedArray, i, values[i]);
+        }
+        return convertedArray;
+    }
+    
+}
diff --git a/src/main/java/org/apache/sling/jcr/contentparser/package-info.java b/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
new file mode 100644
index 0000000..21b7f41
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/contentparser/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Parser for repository content stored in files (e.g. JSON, JCR XML).
+ */
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.sling.jcr.contentparser;
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
new file mode 100644
index 0000000..d99a025
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlContentParserTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ContentParserFactory;
+import org.apache.sling.jcr.contentparser.ContentType;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+public class JcrXmlContentParserTest {
+
+    private File file;
+
+    @Before
+    public void setUp() throws Exception {
+        file = new File("src/test/resources/content-test/content.jcr.xml");
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testParseJcrXml() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
+        Map<String,Object> content = underTest.parse(file);
+        assertNotNull(content);
+        assertEquals("app:Page", content.get("jcr:primaryType"));
+        assertEquals("app:PageContent", ((Map<String,Object>)content.get("jcr:content")).get("jcr:primaryType"));
+    }
+
+    @Test(expected=ParseException.class)
+    public void testParseInvalidJcrXml() throws Exception {
+        file = new File("src/test/resources/invalid-test/invalid.jcr.xml");
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
+        underTest.parse(file);
+    }
+
+    @Test
+    public void testDataTypes() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
+        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> props = getDeep(content, "jcr:content");
+        
+        assertEquals("en", props.get("jcr:title"));
+        assertEquals(true, props.get("includeAside"));
+        assertEquals((Long)1234567890123L, props.get("longProp"));
+        assertEquals(new BigDecimal("1.2345"), props.get("decimalProp"));
+        
+        assertArrayEquals(new String[] { "aa", "bb", "cc" }, (String[])props.get("stringPropMulti"));
+        assertArrayEquals(new Long[] { 1234567890123L, 55L }, (Long[])props.get("longPropMulti"));
+        
+        Calendar calendar = (Calendar)props.get("dateProp");
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+        assertEquals(2014, calendar.get(Calendar.YEAR));
+        assertEquals(9, calendar.get(Calendar.MONTH) + 1);
+        assertEquals(19, calendar.get(Calendar.DAY_OF_MONTH));
+        assertEquals(21, calendar.get(Calendar.HOUR_OF_DAY));
+        assertEquals(20, calendar.get(Calendar.MINUTE));
+        assertEquals(26, calendar.get(Calendar.SECOND));
+        assertEquals(812, calendar.get(Calendar.MILLISECOND));
+    }
+
+    @Test
+    public void testDecodeName() {
+        assertEquals("jcr:title", JcrXmlContentParser.decodeName("jcr:" + ISO9075.encode("title")));
+        assertEquals("sling:123", JcrXmlContentParser.decodeName("sling:" + ISO9075.encode("123")));
+    }
+
+    @Test
+    public void testIgnoreResourcesProperties() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML, new ParserOptions()
+                .ignoreResourceNames(ImmutableSet.of("teaserbar", "aside"))
+                .ignorePropertyNames(ImmutableSet.of("longProp", "jcr:title")));
+        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> props = getDeep(content, "jcr:content");
+        
+        assertEquals("HOME", props.get("navTitle"));
+        assertNull(props.get("jcr:title"));
+        assertNull(props.get("longProp"));
+        
+        assertNull(props.get("teaserbar"));
+        assertNull(props.get("aside"));
+        assertNotNull(props.get("content"));
+    }
+
+    @Test
+    @Ignore
+    public void testSameNamePropertyAndSubResource() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JCR_XML);
+        Map<String,Object> content = underTest.parse(file);
+        Map<String,Object> props = getDeep(content, "jcr:content/teaserbar");
+        // teaserbaritem is a direct property as well as a sub resource
+        assertEquals("test", props.get("teaserbaritem"));
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverterTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverterTest.java
new file mode 100644
index 0000000..c3ec747
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JcrXmlValueConverterTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import static org.apache.sling.jcr.contentparser.impl.JcrXmlValueConverter.parseValue;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.UUID;
+
+import org.junit.Test;
+
+public class JcrXmlValueConverterTest {
+    
+    private static final String NAME = "prop1";
+
+    @Test
+    public void testNull() {
+        assertNull(parseValue(NAME, null));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testInvalid() {
+        parseValue(NAME, "{InvalidType}xyz");
+    }
+
+    @Test
+    public void testString() {
+        assertEquals("myString", parseValue(NAME, "myString"));
+        assertEquals("prop", "myString [ ] { } \\ ,", parseValue(NAME, "myString [ ] { } \\\\ ,"));
+        assertEquals("{myString}", parseValue(NAME, "\\{myString}"));
+        assertEquals("aaa{myString}", parseValue(NAME, "aaa{myString}"));
+        assertEquals("[myString]", parseValue(NAME, "\\[myString]"));
+        assertEquals("aaa[myString]", parseValue(NAME, "aaa[myString]"));
+    }
+
+    @Test
+    public void testStringArray() {
+        assertArrayEquals(new Object[] { "myString1", "myString2" }, (Object[]) parseValue(NAME, "[myString1,myString2]"));
+        assertArrayEquals(new Object[] { "myString1,[]\\äöü߀", "myString2", "myString3 [ ] { } \\ ,", "", "[myString5]", "{myString6}" },
+                (Object[]) parseValue(NAME, "[myString1\\,[]\\\\äöü߀,myString2,myString3 [ ] { } \\\\ \\,,,[myString5],{myString6}]"));
+    }
+
+    @Test
+    public void testBoolean() {
+        assertEquals(true, parseValue(NAME, "{Boolean}true"));
+        assertEquals(false, parseValue(NAME, "{Boolean}false"));
+    }
+
+    @Test
+    public void testBooleanArray() {
+        assertArrayEquals(new Object[] { true, false }, (Object[]) parseValue(NAME, "{Boolean}[true,false]"));
+    }
+
+    @Test
+    public void testLong() {
+        assertEquals(1L, parseValue(NAME, "{Long}1"));
+        assertEquals(10000000000L, parseValue(NAME, "{Long}10000000000"));
+    }
+
+    @Test
+    public void testLongArray() {
+        assertArrayEquals(new Object[] { 1L, 2L }, (Object[]) parseValue(NAME, "{Long}[1,2]"));
+        assertArrayEquals(new Object[] { 10000000000L, 20000000000L }, (Object[]) parseValue(NAME, "{Long}[10000000000,20000000000]"));
+    }
+
+    @Test
+    public void testDouble() {
+        assertEquals(new BigDecimal("1.234"), parseValue(NAME, "{Decimal}1.234"));
+    }
+
+    @Test
+    public void testDoubleArray() {
+        assertArrayEquals(new Object[] { new BigDecimal("1.234"), new BigDecimal("2.345") }, (Object[]) parseValue(NAME, "{Decimal}[1.234,2.345]"));
+    }
+
+    @Test
+    public void testCalendar() {
+        Calendar value = (Calendar)parseValue(NAME, "{Date}2010-09-05T15:10:20.000Z");
+        assertEquals(2010, value.get(Calendar.YEAR));
+        assertEquals(8, value.get(Calendar.MONTH));
+        assertEquals(5, value.get(Calendar.DAY_OF_MONTH));
+    }
+
+    @Test
+    public void testStringArrayRepPrivileges() {
+        assertArrayEquals(new Object[] { "rep:write", "crx:replicate", "jcr:read" }, (Object[]) parseValue(NAME, "{Name}[rep:write,crx:replicate,jcr:read]"));
+    }
+
+    @Test
+    public void testReference() {
+        UUID uuid = UUID.randomUUID();
+        UUID value = (UUID)parseValue(NAME, "{Reference}" + uuid.toString());
+        assertEquals(uuid, value);
+    }
+
+    @Test
+    public void testURI() {
+        URI value = (URI)parseValue(NAME, "{URI}http://www.jodelkaiser.de/");
+        assertEquals("http://www.jodelkaiser.de/", value.toString());
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
new file mode 100644
index 0000000..a98757a
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/JsonContentParserTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import static org.apache.sling.jcr.contentparser.impl.TestUtils.getDeep;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.sling.jcr.contentparser.ContentParser;
+import org.apache.sling.jcr.contentparser.ContentParserFactory;
+import org.apache.sling.jcr.contentparser.ContentType;
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+public class JsonContentParserTest {
+
+    private File file;
+
+    @Before
+    public void setUp() {
+        file = new File("src/test/resources/content-test/content.json");
+    }
+
+    @Test
+    public void testPageJcrPrimaryType() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        assertEquals("app:Page", content.get("jcr:primaryType"));
+    }
+
+    @Test
+    public void testDataTypes() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "toolbar/profiles/jcr:content");
+        assertEquals(true, props.get("hideInNav"));
+
+        assertEquals(1234567890123L, props.get("longProp"));
+        assertEquals(new BigDecimal("1.2345"), props.get("decimalProp"));
+        assertEquals(true, props.get("booleanProp"));
+
+        assertArrayEquals(new Long[] { 1234567890123L, 55L }, (Long[]) props.get("longPropMulti"));
+        assertArrayEquals(new BigDecimal[] { new BigDecimal("1.2345"), new BigDecimal("1.1") }, (BigDecimal[]) props.get("decimalPropMulti"));
+        assertArrayEquals(new Boolean[] { true, false }, (Boolean[]) props.get("booleanPropMulti"));
+    }
+
+    @Test
+    public void testContentProperties() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "jcr:content/header");
+        assertEquals("/content/dam/sample/header.png", props.get("imageReference"));
+    }
+
+    @Test
+    public void testCalendar() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
+                new ParserOptions().detectCalendarValues(true));
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "jcr:content");
+
+        Calendar calendar = (Calendar) props.get("app:lastModified");
+        assertNotNull(calendar);
+
+        calendar.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+
+        assertEquals(2014, calendar.get(Calendar.YEAR));
+        assertEquals(4, calendar.get(Calendar.MONTH) + 1);
+        assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH));
+
+        assertEquals(15, calendar.get(Calendar.HOUR_OF_DAY));
+        assertEquals(11, calendar.get(Calendar.MINUTE));
+        assertEquals(24, calendar.get(Calendar.SECOND));
+    }
+
+    @Test
+    public void testUTF8Chars() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
+        Map<String, Object> content = underTest.parse(file);
+
+        Map<String, Object> props = getDeep(content, "jcr:content");
+
+        assertEquals("äöü߀", props.get("utf8Property"));
+    }
+
+    @Test(expected = ParseException.class)
+    public void testParseInvalidJson() throws Exception {
+        file = new File("src/test/resources/invalid-test/invalid.json");
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
+        Map<String, Object> content = underTest.parse(file);
+        assertNull(content);
+    }
+
+    @Test(expected = ParseException.class)
+    public void testParseInvalidJsonWithObjectList() throws Exception {
+        file = new File("src/test/resources/invalid-test/contentWithObjectList.json");
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON);
+        Map<String, Object> content = underTest.parse(file);
+        assertNull(content);
+    }
+
+    @Test
+    public void testIgnoreResourcesProperties() throws Exception {
+        ContentParser underTest = ContentParserFactory.create(ContentType.JSON,
+                new ParserOptions().ignoreResourceNames(ImmutableSet.of("header", "newslist"))
+                        .ignorePropertyNames(ImmutableSet.of("jcr:title")));
+        Map<String, Object> content = underTest.parse(file);
+        Map<String, Object> props = getDeep(content, "jcr:content");
+
+        assertEquals("Sample Homepage", props.get("pageTitle"));
+        assertNull(props.get("jcr:title"));
+
+        assertNull(props.get("header"));
+        assertNull(props.get("newslist"));
+        assertNotNull(props.get("lead"));
+
+        assertEquals("abc", props.get("refpro1"));
+        assertEquals("def", props.get("pathprop1"));
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/ParserHelperTest.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/ParserHelperTest.java
new file mode 100644
index 0000000..f9e72da
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/ParserHelperTest.java
@@ -0,0 +1,199 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import static org.apache.sling.jcr.contentparser.ParserOptions.DEFAULT_PRIMARY_TYPE;
+import static org.apache.sling.jcr.contentparser.impl.ParserHelper.JCR_PRIMARYTYPE;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.sling.jcr.contentparser.ParseException;
+import org.apache.sling.jcr.contentparser.ParserOptions;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+public class ParserHelperTest {
+
+    @Test
+    public void testEnsureDefaultPrimaryType() {
+        Map<String,Object> content = new HashMap<>();
+        content.put("prop1", "value1");
+
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.ensureDefaultPrimaryType(content);
+        
+        assertEquals(ImmutableMap.<String,Object>of("prop1", "value1", JCR_PRIMARYTYPE, DEFAULT_PRIMARY_TYPE), content);
+    }
+
+    @Test
+    public void testEnsureDefaultPrimaryType_Disabled() {
+        Map<String,Object> content = new HashMap<>();
+        content.put("prop1", "value1");
+
+        ParserHelper underTest = new ParserHelper(new ParserOptions().defaultPrimaryType(null));
+        underTest.ensureDefaultPrimaryType(content);
+        
+        assertEquals(ImmutableMap.<String,Object>of("prop1", "value1"), content);
+    }
+
+    @Test
+    public void testEnsureDefaultPrimaryType_AlreadySet() {
+        Map<String,Object> content = new HashMap<>();
+        content.put("prop1", "value1");
+        content.put(JCR_PRIMARYTYPE, "type1");
+
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.ensureDefaultPrimaryType(content);
+        
+        assertEquals(ImmutableMap.<String,Object>of("prop1", "value1", JCR_PRIMARYTYPE, "type1"), content);
+    }
+
+    @Test
+    public void testTryParseCalendar() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().detectCalendarValues(true));
+        
+        Calendar value = underTest.tryParseCalendar("Tue Apr 22 2014 15:11:24 GMT+0200");
+        assertNotNull(value);
+
+        value.setTimeZone(TimeZone.getTimeZone("GMT+2"));
+
+        assertEquals(2014, value.get(Calendar.YEAR));
+        assertEquals(4, value.get(Calendar.MONTH) + 1);
+        assertEquals(22, value.get(Calendar.DAY_OF_MONTH));
+
+        assertEquals(15, value.get(Calendar.HOUR_OF_DAY));
+        assertEquals(11, value.get(Calendar.MINUTE));
+        assertEquals(24, value.get(Calendar.SECOND));
+    }
+
+    @Test
+    public void testTryParseCalendar_Invalid() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().detectCalendarValues(true));
+        
+        Calendar value = underTest.tryParseCalendar("hello world");
+        assertNull(value);
+
+        value = underTest.tryParseCalendar("");
+        assertNull(value);
+
+        value = underTest.tryParseCalendar(null);
+        assertNull(value);
+    }
+
+    @Test
+    public void testTryParseCalendar_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        
+        Calendar value = underTest.tryParseCalendar("Tue Apr 22 2014 15:11:24 GMT+0200");
+        assertNull(value);
+    }
+
+    @Test
+    public void testIgnoreProperty() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().ignorePropertyNames(ImmutableSet.of("prop1", "jcr:prop2")));
+        
+        assertTrue(underTest.ignoreProperty("prop1"));
+        assertTrue(underTest.ignoreProperty("jcr:prop2"));
+        assertFalse(underTest.ignoreProperty("prop3"));
+    }
+
+    @Test
+    public void testIgnoreProperty_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        
+        assertFalse(underTest.ignoreProperty("prop1"));
+        assertFalse(underTest.ignoreProperty("jcr:prop2"));
+        assertFalse(underTest.ignoreProperty("prop3"));
+    }
+
+    @Test
+    public void testIgnoreResource() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().ignoreResourceNames(ImmutableSet.of("node1", "jcr:node2")));
+        
+        assertTrue(underTest.ignoreResource("node1"));
+        assertTrue(underTest.ignoreResource("jcr:node2"));
+        assertFalse(underTest.ignoreResource("node3"));
+    }
+
+    @Test
+    public void testIgnoreResource_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        
+        assertFalse(underTest.ignoreResource("node1"));
+        assertFalse(underTest.ignoreResource("jcr:node2"));
+        assertFalse(underTest.ignoreResource("node3"));
+    }
+
+    @Test
+    public void testCleanupPropertyName() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+
+        assertEquals("prop1", underTest.cleanupPropertyName("jcr:reference:prop1"));
+        assertEquals("prop2", underTest.cleanupPropertyName("jcr:path:prop2"));
+        assertEquals("jcr:xyz:prop3", underTest.cleanupPropertyName("jcr:xyz:prop3"));
+    }
+
+    @Test
+    public void testCleanupPropertyName_Disabled() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions().removePropertyNamePrefixes(null));
+
+        assertEquals("jcr:reference:prop1", underTest.cleanupPropertyName("jcr:reference:prop1"));
+        assertEquals("jcr:path:prop2", underTest.cleanupPropertyName("jcr:path:prop2"));
+        assertEquals("jcr:xyz:prop3", underTest.cleanupPropertyName("jcr:xyz:prop3"));
+    }
+
+    @Test
+    public void testConvertSingleTypeArray() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+
+        assertArrayEquals(new Object[0], (Object[])underTest.convertSingleTypeArray(new Object[0]));
+        assertArrayEquals(new String[] {"value1","value2"}, (String[])underTest.convertSingleTypeArray(new Object[] {"value1","value2"}));
+        assertArrayEquals(new Long[] {1L,2L}, (Long[])underTest.convertSingleTypeArray(new Object[] {1L,2L}));
+    }
+
+    @Test(expected=ParseException.class)
+    public void testConvertSingleTypeArray_WithNull() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.convertSingleTypeArray(new Object[] {"value1",null});
+    }
+
+    @Test(expected=ParseException.class)
+    public void testConvertSingleTypeArray_Map() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.convertSingleTypeArray(new Object[] {ImmutableMap.<String,Object>of("prop1", "value1")});
+    }
+
+    @Test(expected=ParseException.class)
+    public void testConvertSingleTypeArray_MixedType() {
+        ParserHelper underTest = new ParserHelper(new ParserOptions());
+        underTest.convertSingleTypeArray(new Object[] {"value1",1L});
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
new file mode 100644
index 0000000..bd3bb10
--- /dev/null
+++ b/src/test/java/org/apache/sling/jcr/contentparser/impl/TestUtils.java
@@ -0,0 +1,48 @@
+/*
+ * 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.sling.jcr.contentparser.impl;
+
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+public final class TestUtils {
+    
+    private TestUtils() {
+        // static methods only
+    }
+
+    @SuppressWarnings("unchecked")
+    public static Map<String, Object> getDeep(Map<String, Object> map, String path) {
+      String name = StringUtils.substringBefore(path, "/");
+      Object object = map.get(name);
+      if (object == null || !(object instanceof Map)) {
+        return null;
+      }
+      String remainingPath = StringUtils.substringAfter(path, "/");
+      Map<String, Object> childMap = (Map<String, Object>)object;
+      if (StringUtils.isEmpty(remainingPath)) {
+        return childMap;
+      }
+      else {
+        return getDeep(childMap, remainingPath);
+      }
+    }
+    
+}
diff --git a/src/test/resources/content-test/content.jcr.xml b/src/test/resources/content-test/content.jcr.xml
new file mode 100644
index 0000000..7d97cc0
--- /dev/null
+++ b/src/test/resources/content-test/content.jcr.xml
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:app="http://sample.com/jcr/app/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
+    jcr:primaryType="app:Page">
+  <jcr:content
+      jcr:primaryType="app:PageContent"
+      jcr:title="en"
+      sling:resourceType="samples/sample-app/components/content/page/homepage"
+      includeAside="{Boolean}true"
+      includeAsideBar="{Boolean}true"
+      includeTeaserBar="{Boolean}true"
+      includeTeaserbar="{Boolean}true"
+      inheritAside="{Boolean}false"
+      inheritTeaserbar="{Boolean}false"
+      longProp="{Long}1234567890123"
+      decimalProp="{Decimal}1.2345"
+      longPropMulti="{Long}[1234567890123,55]"
+      stringPropMulti="[aa,bb,cc]"
+      dateProp="{Date}2014-09-19T21:20:26.812+02:00"
+      navTitle="HOME"
+      pageTitle="Sample Site">
+    <teaserbar
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarParsys"
+        teaserbaritem="test">
+      <teaserbaritem
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/conference"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="This should help you with your decision"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/user.png"
+          teaserContent="Still not convinced to attend? Need persuasion? Facts for your boss?"
+          title="Why to attend" />
+      <teaserbaritem_0
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/venue"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="More information"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/location.png"
+          teaserContent="Take a look at the new venue for 2013. The Kulturbrauerei in the Prenzlauer Berg district."
+          title="Location" />
+      <teaserbaritem_1
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/conference/call-for-papers"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="Submit your proposal here"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/talk.png"
+          teaserContent="If you have insight and experiences with Apache Sling and want to share them? We are actually asking for your participation!"
+          title="Want to share?" />
+      <teaserbaritem_2
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/teaserbar/teaserbarItem"
+          linkContentRef="/content/samples/en/archive"
+          linkMediaDownload="{Boolean}false"
+          linkTitle="Dive into the archive"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/archive.png"
+          teaserContent="adaptTo() is not a new event. Take a look at what was said and done previously."
+          title="Take a look back" />
+    </teaserbar>
+    <aside
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="samples/sample-app/components/content/aside/asideParsys">
+      <asidesponsorteaser
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaser"
+          title="Sponsors">
+        <images
+            jcr:primaryType="nt:unstructured"
+            sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaserParsys">
+          <asidesponsorteaserit_0
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaserItem"
+              imageHeight="41"
+              imageWidth="200"
+              linkExternalRef="http://www.pro-vision.de"
+              linkType="external"
+              linkWindowFeatures="default"
+              linkWindowTarget="_blank"
+              mediaRef="/content/dam/samples/content/provision-logo.png" />
+        </images>
+      </asidesponsorteaser>
+      <asidesocialteaser
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/aside/asideSocialTeaser"
+          title="Follow us">
+        <images
+            jcr:primaryType="nt:unstructured"
+            sling:resourceType="samples/sample-app/components/content/aside/asideSponsorTeaserParsys">
+          <asidesocialteaserite
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/aside/asideSocialTeaserItem"
+              linkExternalRef="http://twitter.com/adaptto"
+              linkMediaDownload="{Boolean}false"
+              linkTitle="@adaptTo"
+              linkType="external"
+              linkWindowFeatures="default"
+              linkWindowTarget="_blank"
+              mediaRef="/content/dam/samples/content/twitter-icon.png"
+              title="on twitter" />
+        </images>
+      </asidesocialteaser>
+    </aside>
+    <content
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="sample/wcm/parsys/components/parsys">
+      <contentrichtext
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/common/contentRichText"
+          text="&lt;p&gt;adaptTo() is a meetup in Berlin focused on Apache Sling including Apache Jackrabbit and Apache Felix and is addressed to all using this stack or parts of it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a data=&quot;{&amp;quot;linkType&amp;quot;:&amp;quot;internal&amp;quot;,&amp;quot;linkContentRef&amp;quot;:&amp;quot;/content/samples/handler/en/conference&amp;quot;,&amp;quot;linkWindowTarget&amp;quot;:&amp;quot;_self&amp;quot;,&amp;quot;linkWindowFeatures&amp;quot;:&amp;quot;defa [...]
+      <contentheadline
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/common/contentHeadline"
+          headline="Extended Call for Papers"
+          smaller="{Boolean}true" />
+      <contentrichtext_0
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/common/contentRichText"
+          text="&lt;p&gt;Although we got some great submissions for adaptTo() 2013, we still have some slots for further sessions. Therefore we extend the timeslot for submissions to the call for papers and for feedback by two weeks. This means you still can submit you submissions till 06.05.2013. We're looking forward to get more of your great talks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a data=&quot;{&amp;quot;linkType&amp;quot;:&amp;quot;internal&amp;quot;,&amp;quot;linkContentRef&amp;quot;:&amp [...]
+    </content>
+    <stage
+        jcr:primaryType="nt:unstructured"
+        sling:resourceType="sample/wcm/parsys/components/parsys">
+      <stageheader
+          jcr:primaryType="nt:unstructured"
+          sling:resourceType="samples/sample-app/components/content/stage/stageheader"
+          linkMediaDownload="{Boolean}false"
+          linkType="internal"
+          linkWindowFeatures="default"
+          linkWindowTarget="_self"
+          mediaRef="/content/dam/samples/content/stageheader-outside2.jpg"
+          subtitle="23.–25. September 2013&#xA;Kulturbrauerei Berlin"
+          title="adaptTo() 2013">
+        <links
+            jcr:primaryType="nt:unstructured"
+            sling:resourceType="samples/sample-app/components/content/stage/stageheaderParsys">
+          <stageheaderlinkitem
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/stage/stageheaderLinkItem"
+              linkContentRef="/content/samples/en/tickets"
+              linkMediaDownload="{Boolean}false"
+              linkTitle="Get tickets now"
+              linkType="internal"
+              linkWindowFeatures="default"
+              linkWindowTarget="_self" />
+          <stageheaderlinkitem_0
+              jcr:primaryType="nt:unstructured"
+              sling:resourceType="samples/sample-app/components/content/stage/stageheaderLinkItem"
+              linkContentRef="/content/samples/en/conference/call-for-papers"
+              linkMediaDownload="{Boolean}false"
+              linkTitle="Submit paper"
+              linkType="internal"
+              linkWindowFeatures="default"
+              linkWindowTarget="_self" />
+        </links>
+      </stageheader>
+    </stage>
+    <image
+        jcr:primaryType="nt:unstructured" />
+  </jcr:content>
+  <tools />
+  <conference />
+</jcr:root>
diff --git a/src/test/resources/content-test/content.json b/src/test/resources/content-test/content.json
new file mode 100644
index 0000000..c30d34e
--- /dev/null
+++ b/src/test/resources/content-test/content.json
@@ -0,0 +1,264 @@
+/* Comment example */
+{
+  "jcr:primaryType": "app:Page",
+  "jcr:createdBy": "admin",
+  "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+  /* Comment example */
+  "jcr:content": {
+    "jcr:primaryType": "app:PageContent",  /* Comment example */
+    "jcr:createdBy": "admin",
+    "jcr:title": "English",
+    "app:template": "sample/templates/homepage",
+    "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+    "app:lastModified": "Tue Apr 22 2014 15:11:24 GMT+0200",
+    "dateISO8601String": "2014-04-22T15:11:24.000+02:00",
+    "pageTitle": "Sample Homepage",
+    "sling:resourceType": "sample/components/homepage",
+    "sling:resourceSuperType": "sample/components/supertype",
+    "app:designPath": "/etc/designs/sample",
+    "app:lastModifiedBy": "admin",
+    "utf8Property": "äöü߀",
+    "jcr:reference:refpro1": "abc",
+    "jcr:path:pathprop1": "def",
+    "par": {
+      "jcr:primaryType": "nt:unstructured",
+      "sling:resourceType": "foundation/components/parsys",
+      "colctrl": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "layout": "2;colctrl-lt0",
+        "jcr:created": "Mon Aug 23 2010 22:02:24 GMT+0200",
+        "jcr:lastModified": "Mon Aug 23 2010 22:02:35 GMT+0200",
+        "sling:resourceType": "foundation/components/parsys/colctrl"
+      },
+      "image": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "fileReference": "/content/dam/sample/portraits/jane_doe.jpg",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:03:39 GMT+0200",
+        "width": "340",
+        "jcr:lastModified": "Sun Oct 31 2010 21:39:50 GMT+0100",
+        "sling:resourceType": "foundation/components/image",
+        "file": {
+          "jcr:primaryType": "nt:file",
+          "jcr:createdBy": "admin",
+          "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+          "jcr:content": {
+            "jcr:primaryType": "nt:resource",
+            "jcr:lastModifiedBy": "anonymous",
+            "jcr:mimeType": "image/jpeg",
+            "jcr:lastModified": "Thu Aug 07 2014 16:32:59 GMT+0200",
+            ":jcr:data": 24377,
+            "jcr:uuid": "eda76d00-b2cd-4b59-878f-c33f71ceaddc"
+          }
+        }
+      },
+      "title_1": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:title": "Strategic Consulting",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:12:08 GMT+0200",
+        "jcr:lastModified": "Wed Oct 27 2010 21:33:24 GMT+0200",
+        "sling:resourceType": "sample/components/title"
+      },
+      "text_1": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Sun Oct 31 2010 21:48:04 GMT+0100",
+        "text": "<p><span class=\"Apple-style-span\" style=\"font-size: 12px;\">In&nbsp;today's competitive market, organizations can face several key geometric challenges:<\/span><\/p>\n<ul>\n<li><span class=\"Apple-style-span\" style=\"font-size: 12px;\">Polyhedral Sectioning<\/span><\/li>\n<li><span class=\"Apple-style-span\" style=\"font-size: 12px;\">Triangulation&nbsp;<\/span><\/li>\n<li><span class=\"Apple-style-span\" style=\"font-size: 12px;\">Trigonometric Calculation<\/span><\ [...]
+        "jcr:lastModified": "Sun Oct 31 2010 21:49:06 GMT+0100",
+        "sling:resourceType": "foundation/components/text",
+        "textIsRich": "true"
+      },
+      "col_break12825937554040": {
+        "jcr:primaryType": "nt:unstructured",
+        "controlType": "break",
+        "sling:resourceType": "foundation/components/parsys/colctrl"
+      },
+      "image_0": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "fileReference": "/content/dam/sample/offices/clean_room.jpg",
+        "height": "226",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:04:46 GMT+0200",
+        "jcr:lastModified": "Fri Nov 05 2010 10:38:15 GMT+0100",
+        "sling:resourceType": "foundation/components/image",
+        "imageRotate": "0",
+        "file": {
+          "jcr:primaryType": "nt:file",
+          "jcr:createdBy": "admin",
+          "jcr:created": "Thu Aug 07 2014 16:32:59 GMT+0200",
+          "jcr:content": {
+            "jcr:primaryType": "nt:resource",
+            "jcr:lastModifiedBy": "anonymous",
+            "jcr:mimeType": "image/jpeg",
+            "jcr:lastModified": "Thu Aug 07 2014 16:32:59 GMT+0200",
+            ":jcr:data": 21142,
+            "jcr:uuid": "6139077f-191f-4337-aaef-55456ebe6784"
+          }
+        }
+      },
+      "title_2": {
+        "jcr:createdBy": "admin",
+        "jcr:title": "Shape Technology",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:12:13 GMT+0200",
+        "jcr:lastModified": "Tue Oct 26 2010 21:16:29 GMT+0200",
+        "sling:resourceType": "sample/components/title"
+      },
+      "text_0": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Mon Aug 23 2010 22:16:30 GMT+0200",
+        "text": "<p>The Sample investment in R&amp;D has done more than solidify our industry leadership role, we have now outpaced our competitors to such an extent that we are in an altogether new space.<\/p>\n<p>This is why our high quality polygons and polyhedra provide the only turnkey solutions across the whole range of euclidean geometry. And our mathematicians are working on the next generation of fractal curves to bring you shapes that are unthinkable today.<\/p>\n<p><\/p>\n<p>< [...]
+        "jcr:lastModified": "Mon Nov 08 2010 20:39:00 GMT+0100",
+        "sling:resourceType": "foundation/components/text",
+        "textIsRich": "true"
+      },
+      "col_end12825937444810": {
+        "jcr:primaryType": "nt:unstructured",
+        "controlType": "end",
+        "sling:resourceType": "foundation/components/parsys/colctrl"
+      }
+    },
+    "header": {
+      "jcr:primaryType": "nt:unstructured",
+      "jcr:title": "trust our experience\r\nto manage your business",
+      "imageReference": "/content/dam/sample/header.png",
+      "text": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eget neque. Nunc condimentum ipsum et orci. Aenean est. Cras eget diam. read more",
+      "sling:resourceType": "sample/components/header"
+    },
+    "newslist": {
+      "jcr:primaryType": "nt:unstructured",
+      "headline": "trust our experience\nto manage your business",
+      "text": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc eget neque. Nunc condimentum ipsum et orci. Aenean est. Cras eget diam. read more",
+      "sling:resourceType": "sample/components/listchildren",
+      "listroot": "/content/sample/en/about/news"
+    },
+    "lead": {
+      "jcr:primaryType": "nt:unstructured",
+      "jcr:title": "World Leader in Applied Geometry ",
+      "jcr:lastModifiedBy": "admin",
+      "text": "Lead Text",
+      "title": "Lead Title",
+      "jcr:description": "Sample has been selling and servicing shapes for over 2000 years. From our beginnings as a small vendor of squares and rectangles we have grown our business into a leading global provider of platonic solids and fractals. Join us as we lead geometry into the future.",
+      "jcr:lastModified": "Wed Jan 19 2011 14:35:29 GMT+0100",
+      "sling:resourceType": "sample/components/lead",
+      "app:annotations": {"jcr:primaryType": "nt:unstructured"}
+    },
+    "image": {
+      "jcr:primaryType": "nt:unstructured",
+      "jcr:lastModifiedBy": "admin",
+      "jcr:lastModified": "Wed Oct 27 2010 21:30:59 GMT+0200",
+      "imageRotate": "0"
+    },
+    "carousel": {
+      "jcr:primaryType": "nt:unstructured",
+      "playSpeed": "6000",
+      "jcr:lastModifiedBy": "admin",
+      "pages": [
+        "/content/sample/en/events/techsummit",
+        "/content/sample/en/events/userconf",
+        "/content/sample/en/events/shapecon",
+        "/content/sample/en/events/dsc"
+      ],
+      "jcr:lastModified": "Tue Oct 05 2010 14:14:27 GMT+0200",
+      "transTime": "1000",
+      "sling:resourceType": "foundation/components/carousel",
+      "listFrom": "static"
+    },
+    "rightpar": {
+      "jcr:primaryType": "nt:unstructured",
+      "sling:resourceType": "foundation/components/parsys",
+      "teaser": {
+        "jcr:primaryType": "nt:unstructured",
+        "jcr:createdBy": "admin",
+        "jcr:lastModifiedBy": "admin",
+        "jcr:created": "Tue Jan 25 2011 11:30:09 GMT+0100",
+        "campaignpath": "/content/campaigns/sample",
+        "jcr:lastModified": "Wed Feb 02 2011 08:40:30 GMT+0100",
+        "sling:resourceType": "personalization/components/teaser"
+      }
+    }
+  },
+  "toolbar": {
+    "jcr:primaryType": "app:Page",
+    "jcr:createdBy": "admin",
+    "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+    "jcr:content": {
+      "jcr:primaryType": "app:PageContent",
+      "subtitle": "Contains the toolbar",
+      "jcr:createdBy": "admin",
+      "jcr:title": "Toolbar",
+      "app:template": "sample/templates/contentpage",
+      "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+      "app:lastModified": "Wed Aug 25 2010 22:51:02 GMT+0200",
+      "hideInNav": "true",
+      "sling:resourceType": "sample/components/contentpage",
+      "app:lastModifiedBy": "admin",
+      "par": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "foundation/components/parsys"
+      },
+      "rightpar": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "foundation/components/iparsys",
+        "iparsys_fake_par": {
+          "jcr:primaryType": "nt:unstructured",
+          "sling:resourceType": "foundation/components/iparsys/par"
+        }
+      }
+    },
+    "profiles": {
+      "jcr:primaryType": "app:Page",
+      "jcr:createdBy": "admin",
+      "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+      "jcr:content": {
+        "jcr:primaryType": "app:PageContent",
+        "jcr:mixinTypes": ["type1","type2"],
+        "jcr:createdBy": "admin",
+        "jcr:title": "Profiles",
+        "app:template": "sample/templates/contentpage",
+        "jcr:created": "Thu Aug 07 2014 16:33:00 GMT+0200",
+        "app:lastModified": "Thu Nov 05 2009 20:27:13 GMT+0100",
+        "hideInNav": true,
+        "sling:resourceType": "sample/components/contentpage",
+        "app:lastModifiedBy": "admin",
+        "longProp": 1234567890123,
+        "decimalProp": 1.2345,
+        "booleanProp": true,
+        "longPropMulti": [1234567890123,55],
+        "decimalPropMulti": [1.2345,1.1],
+        "booleanPropMulti": [true,false],
+        "stringPropMulti": ["aa","bb","cc"],
+        "par": {
+          "jcr:primaryType": "nt:unstructured",
+          "sling:resourceType": "foundation/components/parsys",
+          "textimage": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "foundation/components/textimage"
+          },
+          "mygadgets": {
+            "jcr:primaryType": "nt:unstructured",
+            "gadgets": "http://customer.meteogroup.de/meteogroup/gadgets/wetter24.xml\nhttp://germanweatherradar.googlecode.com/svn/trunk/german-weather-radar.xml\nhttp://www.digitalpowered.info/gadget/ski.pictures.xml\nhttp://www.canbuffi.de/gadgets/clock/clock.xml",
+            "sling:resourceType": "personalization/components/mygadgets"
+          }
+        },
+        "rightpar": {
+          "jcr:primaryType": "nt:unstructured",
+          "sling:resourceType": "foundation/components/iparsys",
+          "iparsys_fake_par": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "foundation/components/iparsys/par"
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/src/test/resources/invalid-test/contentWithObjectList.json b/src/test/resources/invalid-test/contentWithObjectList.json
new file mode 100644
index 0000000..e4527a0
--- /dev/null
+++ b/src/test/resources/invalid-test/contentWithObjectList.json
@@ -0,0 +1,14 @@
+{
+  "prop1": "value1",
+  "childObject": {
+    "prop2": "value2"
+  },
+  "childObjectList": [
+    {
+      "prop1": "value1"
+    },
+    {
+      "prop2": "value2"
+    }
+  ]
+}
diff --git a/src/test/resources/invalid-test/invalid.jcr.xml b/src/test/resources/invalid-test/invalid.jcr.xml
new file mode 100644
index 0000000..7df8a70
--- /dev/null
+++ b/src/test/resources/invalid-test/invalid.jcr.xml
@@ -0,0 +1 @@
+This is invalid xml.
diff --git a/src/test/resources/invalid-test/invalid.json b/src/test/resources/invalid-test/invalid.json
new file mode 100644
index 0000000..59fc86c
--- /dev/null
+++ b/src/test/resources/invalid-test/invalid.json
@@ -0,0 +1 @@
+This is invalid json.

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.