You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/06/13 12:58:22 UTC

[02/21] [OLINGO-317] First presentable state

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
index 61667ac..00f0d3f 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityDeserializer.java
@@ -18,12 +18,6 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.io.IOException;
 import java.net.URI;
 import java.util.ArrayList;
@@ -34,26 +28,35 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.domain.ODataLinkType;
 import org.apache.olingo.commons.api.domain.ODataOperation;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
 /**
  * Reads JSON string into an entity.
  * <br/>
  * If metadata information is available, the corresponding entity fields and content will be populated.
  */
-public class JSONEntityDeserializer extends AbstractJsonDeserializer<JSONEntityImpl> {
+public class JSONEntityDeserializer extends JsonDeserializer {
+
+  public JSONEntityDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONEntityImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<Entity> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = parser.getCodec().readTree(parser);
 
@@ -61,7 +64,7 @@ public class JSONEntityDeserializer extends AbstractJsonDeserializer<JSONEntityI
       throw new JsonParseException("Expected OData Entity, found EntitySet", parser.getCurrentLocation());
     }
 
-    final JSONEntityImpl entity = new JSONEntityImpl();
+    final EntityImpl entity = new EntityImpl();
 
     final URI contextURL;
     if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
@@ -212,6 +215,6 @@ public class JSONEntityDeserializer extends AbstractJsonDeserializer<JSONEntityI
 
     populate(entity, entity.getProperties(), tree, parser.getCodec());
 
-    return new ResWrap<JSONEntityImpl>(contextURL, metadataETag, entity);
+    return new ResWrap<Entity>(contextURL, metadataETag, entity);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
deleted file mode 100644
index 57db805..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntityImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * A single entity, represented via JSON.
- */
-@JsonSerialize(using = JSONEntitySerializer.class)
-@JsonDeserialize(using = JSONEntityDeserializer.class)
-public class JSONEntityImpl extends AbstractEntity {
-
-  private static final long serialVersionUID = -5275365545400797758L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
index 8ece3ba..36e7ae1 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySerializer.java
@@ -18,11 +18,9 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
@@ -34,22 +32,23 @@ import org.apache.olingo.commons.api.domain.ODataOperation;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
+import com.fasterxml.jackson.core.JsonGenerator;
+
 /**
  * Writes out JSON string from an entity.
  */
-public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl> {
+public class JSONEntitySerializer extends JsonSerializer {
 
-  @Override
-  protected void doSerialize(final JSONEntityImpl entity, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  public JSONEntitySerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-    doContainerSerialize(new ResWrap<JSONEntityImpl>((URI) null, null, entity), jgen, provider);
+  protected void doSerialize(final Entity entity, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<Entity>((URI) null, null, entity), jgen);
   }
 
-  @Override
-  protected void doContainerSerialize(
-          final ResWrap<JSONEntityImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  protected void doContainerSerialize(final ResWrap<Entity> container, final JsonGenerator jgen)
+      throws IOException {
 
     final Entity entity = container.getPayload();
 
@@ -58,8 +57,8 @@ public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl>
     if (serverMode) {
       if (container.getContextURL() != null) {
         jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
-                ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
-                container.getContextURL().getURI().toASCIIString());
+            ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+            container.getContextURL().getURI().toASCIIString());
       }
       if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
         jgen.writeStringField(Constants.JSON_METADATA_ETAG, container.getMetadataETag());
@@ -72,7 +71,7 @@ public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl>
 
     if (StringUtils.isNotBlank(entity.getType())) {
       jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE),
-              new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
+          new EdmTypeInfo.Builder().setTypeExpression(entity.getType()).build().external(version));
     }
 
     if (entity.getId() != null) {
@@ -89,11 +88,11 @@ public class JSONEntitySerializer extends AbstractJsonSerializer<JSONEntityImpl>
 
     if (serverMode && entity.getEditLink() != null && StringUtils.isNotBlank(entity.getEditLink().getHref())) {
       jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK),
-              entity.getEditLink().getHref());
+          entity.getEditLink().getHref());
 
       if (entity.isMediaEntity()) {
         jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK),
-                entity.getEditLink().getHref() + "/$value");
+            entity.getEditLink().getHref() + "/$value");
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
index 241dcbc..e4cd3ab 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetDeserializer.java
@@ -18,31 +18,34 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.io.IOException;
 import java.net.URI;
 import java.util.Iterator;
 import java.util.Map;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.EntitySet;
 import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 
 /**
  * Reads JSON string into an entity set.
  * <br/>
  * If metadata information is available, the corresponding entity fields and content will be populated.
  */
-public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEntitySetImpl> {
+public class JSONEntitySetDeserializer extends JsonDeserializer {
+
+  public JSONEntitySetDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONEntitySetImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<EntitySet> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
 
@@ -50,9 +53,9 @@ public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEnti
       return null;
     }
 
-    final JSONEntitySetImpl entitySet = new JSONEntitySetImpl();
+    final EntitySetImpl entitySet = new EntitySetImpl();
 
-    final URI contextURL;
+    URI contextURL;
     if (tree.hasNonNull(Constants.JSON_CONTEXT)) {
       contextURL = URI.create(tree.get(Constants.JSON_CONTEXT).textValue());
       tree.remove(Constants.JSON_CONTEXT);
@@ -88,11 +91,10 @@ public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEnti
     }
 
     if (tree.hasNonNull(Constants.VALUE)) {
+      final JSONEntityDeserializer entityDeserializer = new JSONEntityDeserializer(version, serverMode);
       for (final Iterator<JsonNode> itor = tree.get(Constants.VALUE).iterator(); itor.hasNext();) {
         entitySet.getEntities().add(
-                itor.next().traverse(parser.getCodec()).<ResWrap<JSONEntityImpl>>readValueAs(
-                        new TypeReference<JSONEntityImpl>() {
-                        }).getPayload());
+            entityDeserializer.doDeserialize(itor.next().traverse(parser.getCodec())).getPayload());
       }
       tree.remove(Constants.VALUE);
     }
@@ -109,6 +111,6 @@ public class JSONEntitySetDeserializer extends AbstractJsonDeserializer<JSONEnti
       }
     }
 
-    return new ResWrap<JSONEntitySetImpl>(contextURL, metadataETag, entitySet);
+    return new ResWrap<EntitySet>(contextURL, metadataETag, entitySet);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
deleted file mode 100644
index dac67cd..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * List of entries, represented via JSON.
- *
- * @see JSONEntry
- */
-@JsonDeserialize(using = JSONEntitySetDeserializer.class)
-@JsonSerialize(using = JSONEntitySetSerializer.class)
-public class JSONEntitySetImpl extends AbstractEntitySet {
-
-  private static final long serialVersionUID = -3576372289800799417L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
index 40eb8e6..1670259 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONEntitySetSerializer.java
@@ -18,48 +18,47 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 
-public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySetImpl> {
+import com.fasterxml.jackson.core.JsonGenerator;
 
-  @Override
-  protected void doSerialize(
-          final JSONEntitySetImpl entitySet, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+public class JSONEntitySetSerializer extends JsonSerializer {
 
-    doContainerSerialize(new ResWrap<JSONEntitySetImpl>((URI) null, null, entitySet), jgen, provider);
+  public JSONEntitySetSerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
   }
 
-  @Override
-  protected void doContainerSerialize(
-          final ResWrap<JSONEntitySetImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  protected void doSerialize(final EntitySet entitySet, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<EntitySet>((URI) null, null, entitySet), jgen);
+  }
+
+  protected void doContainerSerialize(final ResWrap<EntitySet> container, final JsonGenerator jgen)
+      throws IOException {
 
-    final JSONEntitySetImpl entitySet = container.getPayload();
+    final EntitySet entitySet = container.getPayload();
 
     jgen.writeStartObject();
 
     if (serverMode) {
       if (container.getContextURL() != null) {
         jgen.writeStringField(version.compareTo(ODataServiceVersion.V40) >= 0
-                ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
-                container.getContextURL().getURI().toASCIIString());
+            ? Constants.JSON_CONTEXT : Constants.JSON_METADATA,
+            container.getContextURL().getURI().toASCIIString());
       }
 
       if (version.compareTo(ODataServiceVersion.V40) >= 0 && StringUtils.isNotBlank(container.getMetadataETag())) {
         jgen.writeStringField(
-                Constants.JSON_METADATA_ETAG,
-                container.getMetadataETag());
+            Constants.JSON_METADATA_ETAG,
+            container.getMetadataETag());
       }
     }
 
@@ -67,15 +66,15 @@ public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySe
       jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_ID), entitySet.getId().toASCIIString());
     }
     jgen.writeNumberField(version.getJSONMap().get(ODataServiceVersion.JSON_COUNT),
-            entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
+        entitySet.getCount() == null ? entitySet.getEntities().size() : entitySet.getCount());
     if (serverMode) {
       if (entitySet.getNext() != null) {
         jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK),
-                entitySet.getNext().toASCIIString());
+            entitySet.getNext().toASCIIString());
       }
       if (entitySet.getDeltaLink() != null) {
         jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK),
-                entitySet.getDeltaLink().toASCIIString());
+            entitySet.getDeltaLink().toASCIIString());
       }
     }
 
@@ -84,10 +83,12 @@ public class JSONEntitySetSerializer extends AbstractJsonSerializer<JSONEntitySe
     }
 
     jgen.writeArrayFieldStart(Constants.VALUE);
+    final JSONEntitySerializer entitySerializer = new JSONEntitySerializer(version, serverMode);
     for (Entity entity : entitySet.getEntities()) {
-      jgen.writeObject(entity);
+      entitySerializer.doSerialize(entity, jgen);
     }
-
     jgen.writeEndArray();
+
+    jgen.writeEndObject();
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
index 36818a9..1803c10 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
@@ -18,28 +18,29 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.io.IOException;
-import java.net.URI;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+
 import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.domain.ODataErrorDetail;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 
-public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODataErrorImpl> {
+public class JSONODataErrorDeserializer extends JsonDeserializer {
+
+  public JSONODataErrorDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONODataErrorImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ODataError doDeserialize(final JsonParser parser) throws IOException {
 
-    final JSONODataErrorImpl error = new JSONODataErrorImpl();
+    final ODataErrorImpl error = new ODataErrorImpl();
 
     final ObjectNode tree = parser.getCodec().readTree(parser);
     if (tree.has(jsonError)) {
@@ -60,11 +61,12 @@ public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODa
         error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
       }
       if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
-        final List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
-        for (final Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
-          details.add(itor.next().traverse(parser.getCodec()).<ResWrap<JSONODataErrorDetailImpl>>readValueAs(
-                  new TypeReference<JSONODataErrorDetailImpl>() {
-                  }).getPayload());
+        List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
+        JSONODataErrorDetailDeserializer detailDeserializer =
+            new JSONODataErrorDetailDeserializer(version, serverMode);
+        for (Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
+          details.add(detailDeserializer.doDeserialize(itor.next().traverse(parser.getCodec()))
+              .getPayload());
         }
 
         error.setDetails(details);
@@ -79,6 +81,6 @@ public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODa
       }
     }
 
-    return new ResWrap<JSONODataErrorImpl>((URI) null, null, error);
+    return error;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
index 38ea043..6fe51ce 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
@@ -18,23 +18,26 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.domain.ODataErrorDetail;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
 
-public class JSONODataErrorDetailDeserializer extends AbstractJsonDeserializer<JSONODataErrorDetailImpl> {
+public class JSONODataErrorDetailDeserializer extends JsonDeserializer {
+
+  public JSONODataErrorDetailDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONODataErrorDetailImpl> doDeserialize(
-          final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<ODataErrorDetail> doDeserialize(final JsonParser parser) throws IOException {
 
-    final JSONODataErrorDetailImpl error = new JSONODataErrorDetailImpl();
+    final ODataErrorDetailImpl error = new ODataErrorDetailImpl();
     final JsonNode errorNode = parser.getCodec().readTree(parser);
     if (errorNode.has(Constants.ERROR_CODE)) {
       error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
@@ -51,6 +54,6 @@ public class JSONODataErrorDetailDeserializer extends AbstractJsonDeserializer<J
       error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
     }
 
-    return new ResWrap<JSONODataErrorDetailImpl>((URI) null, null, error);
+    return new ResWrap<ODataErrorDetail>((URI) null, null, error);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
deleted file mode 100644
index 49f3159..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-/*
- * JSONODataErrorDetailImpl, using the JSONODataErrorDetailDeserializer similar to JSONODataErrorImpl's.
- */
-@JsonDeserialize(using = JSONODataErrorDetailDeserializer.class)
-public class JSONODataErrorDetailImpl implements ODataErrorDetail {
-
-  private String code;
-
-  private String message;
-
-  private String target;
-
-  @Override
-  public String getCode() {
-    return code;
-  }
-
-  public void setCode(final String code) {
-    this.code = code;
-  }
-
-  @Override
-  public String getMessage() {
-    return message;
-  }
-
-  public void setMessage(final String message) {
-    this.message = message;
-  }
-
-  @Override
-  public String getTarget() {
-    return target;
-  }
-
-  public void setTarget(final String target) {
-    this.target = target;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java
deleted file mode 100644
index c455d2d..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorImpl.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = JSONODataErrorDeserializer.class)
-public class JSONODataErrorImpl extends AbstractODataError {
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
index ea2a9df..465250a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyDeserializer.java
@@ -18,37 +18,39 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import java.io.IOException;
 import java.net.URI;
 import java.util.Iterator;
 import java.util.Map;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.Property;
 import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
 /**
- * Parse JSON string into <tt>JSONPropertyImpl</tt>.
- *
- * @see JSONPropertyImpl
+ * Parse JSON string into <tt>Property</tt>.
  */
-public class JSONPropertyDeserializer extends AbstractJsonDeserializer<JSONPropertyImpl> {
+public class JSONPropertyDeserializer extends JsonDeserializer {
+
+  public JSONPropertyDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-  @Override
-  protected ResWrap<JSONPropertyImpl> doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
+  protected ResWrap<Property> doDeserialize(final JsonParser parser) throws IOException {
 
     final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
 
     final String metadataETag;
     final URI contextURL;
-    final JSONPropertyImpl property = new JSONPropertyImpl();
+    final PropertyImpl property = new PropertyImpl();
 
     if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
       metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
@@ -97,6 +99,6 @@ public class JSONPropertyDeserializer extends AbstractJsonDeserializer<JSONPrope
       }
     }
 
-    return new ResWrap<JSONPropertyImpl>(contextURL, metadataETag, property);
+    return new ResWrap<Property>(contextURL, metadataETag, property);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
deleted file mode 100644
index 1018666..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-/**
- * A single property (primitive, complex or collection) represented via JSON.
- */
-@JsonSerialize(using = JSONPropertySerializer.class)
-@JsonDeserialize(using = JSONPropertyDeserializer.class)
-public class JSONPropertyImpl extends AbstractProperty {
-
-  private static final long serialVersionUID = 553414431536637434L;
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
index 1a7b908..1a82a3b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
@@ -18,37 +18,34 @@
  */
 package org.apache.olingo.commons.core.data;
 
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.SerializerProvider;
 import java.io.IOException;
 import java.net.URI;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.edm.EdmTypeInfo;
 
+import com.fasterxml.jackson.core.JsonGenerator;
+
 /**
- * Writes out JSON string from <tt>JSONPropertyImpl</tt>.
- *
- * @see JSONPropertyImpl
+ * Writes out JSON string from <tt>PropertyImpl</tt>.
  */
-public class JSONPropertySerializer extends AbstractJsonSerializer<JSONPropertyImpl> {
+public class JSONPropertySerializer extends JsonSerializer {
 
-  @Override
-  protected void doSerialize(final JSONPropertyImpl property, final JsonGenerator jgen,
-          final SerializerProvider provider) throws IOException, JsonProcessingException {
+  public JSONPropertySerializer(final ODataServiceVersion version, final boolean serverMode) {
+    super(version, serverMode);
+  }
 
-    doContainerSerialize(new ResWrap<JSONPropertyImpl>((URI) null, null, property), jgen, provider);
+  protected void doSerialize(final Property property, final JsonGenerator jgen) throws IOException {
+    doContainerSerialize(new ResWrap<Property>((URI) null, null, property), jgen);
   }
 
-  @Override
-  protected void doContainerSerialize(
-          final ResWrap<JSONPropertyImpl> container, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
+  protected void doContainerSerialize(final ResWrap<Property> container, final JsonGenerator jgen)
+          throws IOException {
 
     final Property property = container.getPayload();
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java
new file mode 100755
index 0000000..0ecd7f3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonDeserializer.java
@@ -0,0 +1,463 @@
+/*
+ * 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.olingo.commons.core.data;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.ComplexValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.domain.ODataPropertyType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.op.ODataDeserializer;
+import org.apache.olingo.commons.api.op.ODataDeserializerException;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.ObjectCodec;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class JsonDeserializer implements ODataDeserializer {
+
+  protected final Pattern CUSTOM_ANNOTATION = Pattern.compile("(.+)@(.+)\\.(.+)");
+  protected final ODataServiceVersion version;
+  protected final boolean serverMode;
+
+  protected String jsonType;
+  protected String jsonId;
+  protected String jsonETag;
+  protected String jsonReadLink;
+  protected String jsonEditLink;
+  protected String jsonMediaEditLink;
+  protected String jsonMediaReadLink;
+  protected String jsonMediaContentType;
+  protected String jsonMediaETag;
+  protected String jsonAssociationLink;
+  protected String jsonNavigationLink;
+  protected String jsonCount;
+  protected String jsonNextLink;
+  protected String jsonDeltaLink;
+  protected String jsonError;
+
+  private JSONGeoValueDeserializer geoDeserializer;
+
+  private JsonParser parser;
+
+  public JsonDeserializer(final ODataServiceVersion version, final boolean serverMode) {
+    this.version = version;
+    this.serverMode = serverMode;
+
+    jsonType = version.getJSONMap().get(ODataServiceVersion.JSON_TYPE);
+    jsonId = version.getJSONMap().get(ODataServiceVersion.JSON_ID);
+    jsonETag = version.getJSONMap().get(ODataServiceVersion.JSON_ETAG);
+    jsonReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_READ_LINK);
+    jsonEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK);
+    jsonMediaReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK);
+    jsonMediaEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK);
+    jsonMediaContentType = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE);
+    jsonMediaETag = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG);
+    jsonAssociationLink = version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK);
+    jsonNavigationLink = version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK);
+    jsonCount = version.getJSONMap().get(ODataServiceVersion.JSON_COUNT);
+    jsonNextLink = version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK);
+    jsonDeltaLink = version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK);
+    jsonError = version.getJSONMap().get(ODataServiceVersion.JSON_ERROR);
+}
+
+  private JSONGeoValueDeserializer getGeoDeserializer() {
+    if (geoDeserializer == null) {
+      geoDeserializer = new JSONGeoValueDeserializer(version);
+    }
+    return geoDeserializer;
+  }
+
+  protected String getJSONAnnotation(final String string) {
+    return StringUtils.prependIfMissing(string, "@");
+  }
+
+  protected String getTitle(final Map.Entry<String, JsonNode> entry) {
+    return entry.getKey().substring(0, entry.getKey().indexOf('@'));
+  }
+
+  protected String setInline(final String name, final String suffix, final JsonNode tree,
+      final ObjectCodec codec, final LinkImpl link) throws IOException {
+
+    final String entityNamePrefix = name.substring(0, name.indexOf(suffix));
+    if (tree.has(entityNamePrefix)) {
+      final JsonNode inline = tree.path(entityNamePrefix);
+      JSONEntityDeserializer entityDeserializer = new JSONEntityDeserializer(version, serverMode);
+
+      if (inline instanceof ObjectNode) {
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+        link.setInlineEntity(entityDeserializer.doDeserialize(inline.traverse(codec)).getPayload());
+
+      } else if (inline instanceof ArrayNode) {
+        link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
+
+        EntitySet entitySet = new EntitySetImpl();
+        Iterator<JsonNode> entries = ((ArrayNode) inline).elements();
+        while (entries.hasNext()) {
+          entitySet.getEntities().add(
+              entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
+        }
+
+        link.setInlineEntitySet(entitySet);
+      }
+    }
+    return entityNamePrefix;
+  }
+
+  protected void links(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+    if (serverMode) {
+      serverLinks(field, linked, toRemove, tree, codec);
+    } else {
+      clientLinks(field, linked, toRemove, tree, codec);
+    }
+  }
+
+  private void clientLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+
+    if (field.getKey().endsWith(jsonNavigationLink)) {
+      final LinkImpl link = new LinkImpl();
+      link.setTitle(getTitle(field));
+      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
+
+      if (field.getValue().isValueNode()) {
+        link.setHref(field.getValue().textValue());
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+      }
+
+      linked.getNavigationLinks().add(link);
+
+      toRemove.add(field.getKey());
+      toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, codec, link));
+    } else if (field.getKey().endsWith(jsonAssociationLink)) {
+      final LinkImpl link = new LinkImpl();
+      link.setTitle(getTitle(field));
+      link.setRel(version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL) + getTitle(field));
+      link.setHref(field.getValue().textValue());
+      link.setType(ODataLinkType.ASSOCIATION.toString());
+      linked.getAssociationLinks().add(link);
+
+      toRemove.add(field.getKey());
+    }
+  }
+
+  private void serverLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
+      final JsonNode tree, final ObjectCodec codec) throws IOException {
+
+    if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX)
+        || field.getKey().endsWith(jsonNavigationLink)) {
+
+      if (field.getValue().isValueNode()) {
+        final String suffix = field.getKey().replaceAll("^.*@", "@");
+
+        final LinkImpl link = new LinkImpl();
+        link.setTitle(getTitle(field));
+        link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
+        link.setHref(field.getValue().textValue());
+        link.setType(ODataLinkType.ENTITY_NAVIGATION.toString());
+        linked.getNavigationLinks().add(link);
+
+        toRemove.add(setInline(field.getKey(), suffix, tree, codec, link));
+      } else if (field.getValue().isArray()) {
+        for (final Iterator<JsonNode> itor = field.getValue().elements(); itor.hasNext();) {
+          final JsonNode node = itor.next();
+
+          final LinkImpl link = new LinkImpl();
+          link.setTitle(getTitle(field));
+          link.setRel(version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + getTitle(field));
+          link.setHref(node.asText());
+          link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
+          linked.getNavigationLinks().add(link);
+          toRemove.add(setInline(field.getKey(), Constants.JSON_BIND_LINK_SUFFIX, tree, codec, link));
+        }
+      }
+      toRemove.add(field.getKey());
+    }
+  }
+
+  private Map.Entry<ODataPropertyType, EdmTypeInfo> guessPropertyType(final JsonNode node) {
+    ODataPropertyType type;
+    EdmTypeInfo typeInfo = null;
+
+    if (node.isValueNode() || node.isNull()) {
+      type = ODataPropertyType.PRIMITIVE;
+
+      EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.String;
+      if (node.isShort()) {
+        kind = EdmPrimitiveTypeKind.Int16;
+      } else if (node.isInt()) {
+        kind = EdmPrimitiveTypeKind.Int32;
+      } else if (node.isLong()) {
+        kind = EdmPrimitiveTypeKind.Int64;
+      } else if (node.isBoolean()) {
+        kind = EdmPrimitiveTypeKind.Boolean;
+      } else if (node.isFloat()) {
+        kind = EdmPrimitiveTypeKind.Single;
+      } else if (node.isDouble()) {
+        kind = EdmPrimitiveTypeKind.Double;
+      } else if (node.isBigDecimal()) {
+        kind = EdmPrimitiveTypeKind.Decimal;
+      }
+      typeInfo = new EdmTypeInfo.Builder().setTypeExpression(kind.getFullQualifiedName().toString()).build();
+    } else if (node.isArray()) {
+      type = ODataPropertyType.COLLECTION;
+    } else if (node.isObject()) {
+      if (node.has(Constants.ATTR_TYPE)) {
+        type = ODataPropertyType.PRIMITIVE;
+        typeInfo = new EdmTypeInfo.Builder().
+            setTypeExpression("Edm.Geography" + node.get(Constants.ATTR_TYPE).asText()).build();
+      } else {
+        type = ODataPropertyType.COMPLEX;
+      }
+    } else {
+      type = ODataPropertyType.EMPTY;
+    }
+
+    return new SimpleEntry<ODataPropertyType, EdmTypeInfo>(type, typeInfo);
+  }
+
+  protected void populate(final Annotatable annotatable, final List<Property> properties,
+      final ObjectNode tree, final ObjectCodec codec) throws IOException {
+
+    String type = null;
+    Annotation annotation = null;
+    for (final Iterator<Map.Entry<String, JsonNode>> itor = tree.fields(); itor.hasNext();) {
+      final Map.Entry<String, JsonNode> field = itor.next();
+      final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
+
+      if (field.getKey().charAt(0) == '@') {
+        final Annotation entityAnnot = new AnnotationImpl();
+        entityAnnot.setTerm(field.getKey().substring(1));
+
+        value(entityAnnot, field.getValue(), codec);
+        if (annotatable != null) {
+          annotatable.getAnnotations().add(entityAnnot);
+        }
+      } else if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
+        type = field.getValue().asText();
+      } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
+        annotation = new AnnotationImpl();
+        annotation.setTerm(customAnnotation.group(2) + "." + customAnnotation.group(3));
+        value(annotation, field.getValue(), codec);
+      } else {
+        final PropertyImpl property = new PropertyImpl();
+        property.setName(field.getKey());
+        property.setType(type == null
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(type).build().internal());
+        type = null;
+
+        value(property, field.getValue(), codec);
+        properties.add(property);
+
+        if (annotation != null) {
+          property.getAnnotations().add(annotation);
+          annotation = null;
+        }
+      }
+    }
+  }
+
+  private Value fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) {
+    final Value value;
+
+    if (node.isNull()) {
+      value = new NullValueImpl();
+    } else {
+      if (typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
+        value = new GeospatialValueImpl(getGeoDeserializer().deserialize(node, typeInfo));
+      } else {
+        value = new PrimitiveValueImpl(node.asText());
+      }
+    }
+
+    return value;
+  }
+
+  private ComplexValue fromComplex(final ObjectNode node, final ObjectCodec codec) throws IOException {
+    final ComplexValue value = version.compareTo(ODataServiceVersion.V40) < 0
+        ? new ComplexValueImpl()
+        : new LinkedComplexValueImpl();
+
+    if (value.isLinkedComplex()) {
+      final Set<String> toRemove = new HashSet<String>();
+      for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
+        final Map.Entry<String, JsonNode> field = itor.next();
+
+        links(field, value.asLinkedComplex(), toRemove, node, codec);
+      }
+      node.remove(toRemove);
+    }
+
+    populate(value.asLinkedComplex(), value.get(), node, codec);
+
+    return value;
+  }
+
+  private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,
+      final ObjectCodec codec) throws IOException {
+
+    final CollectionValueImpl value = new CollectionValueImpl();
+
+    final EdmTypeInfo type = typeInfo == null
+        ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
+
+    while (nodeItor.hasNext()) {
+      final JsonNode child = nodeItor.next();
+
+      if (child.isValueNode()) {
+        if (typeInfo == null || typeInfo.isPrimitiveType()) {
+          value.get().add(fromPrimitive(child, type));
+        } else {
+          value.get().add(new EnumValueImpl(child.asText()));
+        }
+      } else if (child.isContainerNode()) {
+        if (child.has(jsonType)) {
+          ((ObjectNode) child).remove(jsonType);
+        }
+        value.get().add(fromComplex((ObjectNode) child, codec));
+      }
+    }
+
+    return value;
+  }
+
+  protected void value(final Valuable valuable, final JsonNode node, final ObjectCodec codec)
+      throws IOException {
+
+    EdmTypeInfo typeInfo = StringUtils.isBlank(valuable.getType())
+        ? null
+        : new EdmTypeInfo.Builder().setTypeExpression(valuable.getType()).build();
+
+    final Map.Entry<ODataPropertyType, EdmTypeInfo> guessed = guessPropertyType(node);
+    if (typeInfo == null) {
+      typeInfo = guessed.getValue();
+    }
+
+    final ODataPropertyType propType = typeInfo == null
+        ? guessed.getKey()
+        : typeInfo.isCollection()
+            ? ODataPropertyType.COLLECTION
+            : typeInfo.isPrimitiveType()
+                ? ODataPropertyType.PRIMITIVE
+                : node.isValueNode()
+                    ? ODataPropertyType.ENUM
+                    : ODataPropertyType.COMPLEX;
+
+    switch (propType) {
+    case COLLECTION:
+      valuable.setValue(fromCollection(node.elements(), typeInfo, codec));
+      break;
+
+    case COMPLEX:
+      if (node.has(jsonType)) {
+        valuable.setType(node.get(jsonType).asText());
+        ((ObjectNode) node).remove(jsonType);
+      }
+      valuable.setValue(fromComplex((ObjectNode) node, codec));
+      break;
+
+    case ENUM:
+      valuable.setValue(new EnumValueImpl(node.asText()));
+      break;
+
+    case PRIMITIVE:
+      if (valuable.getType() == null && typeInfo != null) {
+        valuable.setType(typeInfo.getFullQualifiedName().toString());
+      }
+      valuable.setValue(fromPrimitive(node, typeInfo));
+      break;
+
+    case EMPTY:
+    default:
+      valuable.setValue(new PrimitiveValueImpl(StringUtils.EMPTY));
+    }
+  }
+
+  @Override
+  public ResWrap<EntitySet> toEntitySet(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JSONEntitySetDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ResWrap<Entity> toEntity(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JSONEntityDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ResWrap<Property> toProperty(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JSONPropertyDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+
+  @Override
+  public ODataError toError(InputStream input) throws ODataDeserializerException {
+    try {
+      parser = new JsonFactory(new ObjectMapper()).createParser(input);
+      return new JSONODataErrorDeserializer(version, serverMode).doDeserialize(parser);
+    } catch (final IOException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
new file mode 100755
index 0000000..e067d88
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JsonSerializer.java
@@ -0,0 +1,315 @@
+/*
+ * 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.olingo.commons.core.data;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.CollectionValue;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.PrimitiveValue;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.Value;
+import org.apache.olingo.commons.api.domain.ODataLinkType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.op.ODataSerializer;
+import org.apache.olingo.commons.api.op.ODataSerializerException;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+
+public class JsonSerializer implements ODataSerializer {
+
+  protected ODataServiceVersion version;
+  protected boolean serverMode;
+
+  private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
+    EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
+    EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
+    EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
+    EdmPrimitiveTypeKind.Decimal
+  };
+
+  private final JSONGeoValueSerializer geoSerializer = new JSONGeoValueSerializer();
+
+  public JsonSerializer(final ODataServiceVersion version, final boolean serverMode) {
+    this.version = version;
+    this.serverMode = serverMode;
+  }
+
+  @Override
+  public <T> void write(Writer writer, T obj) throws ODataSerializerException {
+    try {
+      JsonGenerator json = new JsonFactory().createGenerator(writer);
+      if (obj instanceof EntitySet) {
+        new JSONEntitySetSerializer(version, serverMode).doSerialize((EntitySet) obj, json);
+      } else if (obj instanceof Entity) {
+        new JSONEntitySerializer(version, serverMode).doSerialize((Entity) obj, json);
+      } else if (obj instanceof Property) {
+        new JSONPropertySerializer(version, serverMode).doSerialize((Property) obj, json);
+      } else if (obj instanceof Link) {
+        link((Link) obj, json);
+      }
+      json.flush();
+    } catch (final IOException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public <T> void write(Writer writer, ResWrap<T> container) throws ODataSerializerException {
+    final T obj = container == null ? null : container.getPayload();
+
+    try {
+      JsonGenerator json = new JsonFactory().createGenerator(writer);
+      if (obj instanceof EntitySet) {
+        new JSONEntitySetSerializer(version, serverMode).doContainerSerialize((ResWrap<EntitySet>) container, json);
+      } else if (obj instanceof Entity) {
+        new JSONEntitySerializer(version, serverMode).doContainerSerialize((ResWrap<Entity>) container, json);
+      } else if (obj instanceof Property) {
+        new JSONPropertySerializer(version, serverMode).doSerialize((Property) obj, json);
+      } else if (obj instanceof Link) {
+        link((Link) obj, json);
+      }
+      json.flush();
+    } catch (final IOException e) {
+      throw new ODataSerializerException(e);
+    }
+  }
+
+  protected void link(final Link link, JsonGenerator jgen) throws IOException {
+    jgen.writeStartObject();
+    jgen.writeStringField(Constants.JSON_URL, link.getHref());
+    jgen.writeEndObject();
+  }
+
+  protected void links(final Linked linked, final JsonGenerator jgen) throws IOException {
+    if (serverMode) {
+      serverLinks(linked, jgen);
+    } else {
+      clientLinks(linked, jgen);
+    }
+  }
+
+  protected void clientLinks(final Linked linked, final JsonGenerator jgen) throws IOException {
+    final Map<String, List<String>> entitySetLinks = new HashMap<String, List<String>>();
+    for (Link link : linked.getNavigationLinks()) {
+      for (Annotation annotation : link.getAnnotations()) {
+        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+      }
+
+      ODataLinkType type = null;
+      try {
+        type = ODataLinkType.fromString(version, link.getRel(), link.getType());
+      } catch (IllegalArgumentException e) {
+        // ignore   
+      }
+
+      if (type == ODataLinkType.ENTITY_SET_NAVIGATION) {
+        final List<String> uris;
+        if (entitySetLinks.containsKey(link.getTitle())) {
+          uris = entitySetLinks.get(link.getTitle());
+        } else {
+          uris = new ArrayList<String>();
+          entitySetLinks.put(link.getTitle(), uris);
+        }
+        if (StringUtils.isNotBlank(link.getHref())) {
+          uris.add(link.getHref());
+        }
+      } else {
+        if (StringUtils.isNotBlank(link.getHref())) {
+          jgen.writeStringField(link.getTitle() + Constants.JSON_BIND_LINK_SUFFIX, link.getHref());
+        }
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeFieldName(link.getTitle());
+        new JSONEntitySerializer(version, serverMode).doSerialize(link.getInlineEntity(), jgen);
+      } else if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        JSONEntitySerializer entitySerializer = new JSONEntitySerializer(version, serverMode);
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          entitySerializer.doSerialize(subEntry, jgen);
+        }
+        jgen.writeEndArray();
+      }
+    }
+    for (Map.Entry<String, List<String>> entitySetLink : entitySetLinks.entrySet()) {
+      if (!entitySetLink.getValue().isEmpty()) {
+        jgen.writeArrayFieldStart(entitySetLink.getKey() + Constants.JSON_BIND_LINK_SUFFIX);
+        for (String uri : entitySetLink.getValue()) {
+          jgen.writeString(uri);
+        }
+        jgen.writeEndArray();
+      }
+    }
+  }
+
+  protected void serverLinks(final Linked linked, final JsonGenerator jgen) throws IOException {
+    if (linked instanceof Entity) {
+      for (Link link : ((Entity) linked).getMediaEditLinks()) {
+        if (StringUtils.isNotBlank(link.getHref())) {
+          jgen.writeStringField(
+                  link.getTitle() + StringUtils.prependIfMissing(
+                          version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), "@"),
+                  link.getHref());
+        }
+      }
+    }
+
+    for (Link link : linked.getAssociationLinks()) {
+      if (StringUtils.isNotBlank(link.getHref())) {
+        jgen.writeStringField(
+                link.getTitle() + version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK),
+                link.getHref());
+      }
+    }
+
+    for (Link link : linked.getNavigationLinks()) {
+      for (Annotation annotation : link.getAnnotations()) {
+        valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm());
+      }
+
+      if (StringUtils.isNotBlank(link.getHref())) {
+        jgen.writeStringField(
+                link.getTitle() + version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK),
+                link.getHref());
+      }
+
+      if (link.getInlineEntity() != null) {
+        jgen.writeFieldName(link.getTitle());
+        new JSONEntitySerializer(version, serverMode).doSerialize(link.getInlineEntity(), jgen);
+      } else if (link.getInlineEntitySet() != null) {
+        jgen.writeArrayFieldStart(link.getTitle());
+        JSONEntitySerializer entitySerializer = new JSONEntitySerializer(version, serverMode);
+        for (Entity subEntry : link.getInlineEntitySet().getEntities()) {
+          entitySerializer.doSerialize(subEntry, jgen);
+        }
+        jgen.writeEndArray();
+      }
+    }
+  }
+
+  private void collection(final JsonGenerator jgen, final String itemType, final CollectionValue value)
+          throws IOException {
+
+    jgen.writeStartArray();
+    for (Value item : value.get()) {
+      value(jgen, itemType, item);
+    }
+    jgen.writeEndArray();
+  }
+
+  protected void primitiveValue(final JsonGenerator jgen, final EdmTypeInfo typeInfo, final PrimitiveValue value)
+          throws IOException {
+
+    final boolean isNumber = typeInfo == null
+            ? NumberUtils.isNumber(value.get())
+            : ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind());
+    final boolean isBoolean = typeInfo == null
+            ? (value.get().equalsIgnoreCase(Boolean.TRUE.toString())
+            || value.get().equalsIgnoreCase(Boolean.FALSE.toString()))
+            : typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean;
+
+    if (isNumber) {
+      jgen.writeNumber(value.get());
+    } else if (isBoolean) {
+      jgen.writeBoolean(BooleanUtils.toBoolean(value.get()));
+    } else {
+      jgen.writeString(value.get());
+    }
+  }
+
+  private void value(final JsonGenerator jgen, final String type, final Value value) throws IOException {
+    final EdmTypeInfo typeInfo = type == null
+            ? null
+            : new EdmTypeInfo.Builder().setTypeExpression(type).build();
+
+    if (value == null || value.isNull()) {
+      jgen.writeNull();
+    } else if (value.isPrimitive()) {
+      primitiveValue(jgen, typeInfo, value.asPrimitive());
+    } else if (value.isEnum()) {
+      jgen.writeString(value.asEnum().get());
+    } else if (value.isGeospatial()) {
+      jgen.writeStartObject();
+      geoSerializer.serialize(jgen, value.asGeospatial().get());
+      jgen.writeEndObject();
+    } else if (value.isCollection()) {
+      collection(jgen, typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(), value.asCollection());
+    } else if (value.isComplex()) {
+      jgen.writeStartObject();
+
+      if (typeInfo != null) {
+        jgen.writeStringField(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE), typeInfo.external(version));
+      }
+
+      for (Property property : value.asComplex().get()) {
+        valuable(jgen, property, property.getName());
+      }
+      if (value.isLinkedComplex()) {
+        links(value.asLinkedComplex(), jgen);
+      }
+
+      jgen.writeEndObject();
+    }
+  }
+
+  protected void valuable(final JsonGenerator jgen, final Valuable valuable, final String name) throws IOException {
+    if (!Constants.VALUE.equals(name) && !(valuable instanceof Annotation) && !valuable.getValue().isComplex()) {
+      String type = valuable.getType();
+      if (StringUtils.isBlank(type) && valuable.getValue().isPrimitive() || valuable.getValue().isNull()) {
+        type = EdmPrimitiveTypeKind.String.getFullQualifiedName().toString();
+      }
+      if (StringUtils.isNotBlank(type)) {
+        jgen.writeFieldName(
+                name + StringUtils.prependIfMissing(version.getJSONMap().get(ODataServiceVersion.JSON_TYPE), "@"));
+        jgen.writeString(new EdmTypeInfo.Builder().setTypeExpression(type).build().external(version));
+      }
+    }
+
+    if (valuable instanceof Annotatable) {
+      for (Annotation annotation : ((Annotatable) valuable).getAnnotations()) {
+        valuable(jgen, annotation, name + "@" + annotation.getTerm());
+      }
+    }
+
+    jgen.writeFieldName(name);
+    value(jgen, valuable.getType(), valuable.getValue());
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
new file mode 100755
index 0000000..3367080
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorDetailImpl.java
@@ -0,0 +1,57 @@
+/*
+ * 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.olingo.commons.core.data;
+
+import org.apache.olingo.commons.api.domain.ODataErrorDetail;
+
+public class ODataErrorDetailImpl implements ODataErrorDetail {
+
+  private String code;
+
+  private String message;
+
+  private String target;
+
+  @Override
+  public String getCode() {
+    return code;
+  }
+
+  public void setCode(final String code) {
+    this.code = code;
+  }
+
+  @Override
+  public String getMessage() {
+    return message;
+  }
+
+  public void setMessage(final String message) {
+    this.message = message;
+  }
+
+  @Override
+  public String getTarget() {
+    return target;
+  }
+
+  public void setTarget(final String target) {
+    this.target = target;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
new file mode 100755
index 0000000..e766ae3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataErrorImpl.java
@@ -0,0 +1,89 @@
+/*
+ * 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.olingo.commons.core.data;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.commons.api.domain.ODataError;
+import org.apache.olingo.commons.api.domain.ODataErrorDetail;
+
+/**
+ * Example:
+ * <tt>
+ * {
+ * "error": { "code": "501", "message": "Unsupported functionality", "target": "query", "details": [ { "code": "301",
+ * "target": "$search", "message": "$search query option not supported" } ], "innererror": { "trace": [...], "context":
+ * {...} } } }
+ * </tt>.
+ */
+public class ODataErrorImpl implements ODataError {
+
+  private String code;
+
+  private String message;
+
+  private String target;
+
+  private List<ODataErrorDetail> details;
+
+  private Map<String, String> innerError = new LinkedHashMap<String, String>();
+
+  @Override
+  public String getCode() {
+    return code;
+  }
+
+  public void setCode(final String code) {
+    this.code = code;
+  }
+
+  @Override
+  public String getMessage() {
+    return message;
+  }
+
+  public void setMessage(final String message) {
+    this.message = message;
+  }
+
+  @Override
+  public String getTarget() {
+    return target;
+  }
+
+  public void setTarget(final String target) {
+    this.target = target;
+  }
+
+  @Override
+  public List<ODataErrorDetail> getDetails() {
+    return details;
+  }
+
+  public void setDetails(final List<ODataErrorDetail> detail) {
+    this.details = detail;
+  }
+
+  @Override
+  public Map<String, String> getInnerError() {
+    return innerError;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
deleted file mode 100644
index a6a75b8..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-
-import java.io.IOException;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
-
-  protected ODataServiceVersion version;
-
-  protected boolean serverMode;
-
-  protected String jsonType;
-
-  protected String jsonId;
-
-  protected String jsonETag;
-
-  protected String jsonReadLink;
-
-  protected String jsonEditLink;
-
-  protected String jsonMediaEditLink;
-
-  protected String jsonMediaReadLink;
-
-  protected String jsonMediaContentType;
-
-  protected String jsonMediaETag;
-
-  protected String jsonAssociationLink;
-
-  protected String jsonNavigationLink;
-
-  protected String jsonCount;
-
-  protected String jsonNextLink;
-
-  protected String jsonDeltaLink;
-
-  protected String jsonError;
-
-  protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
-          throws IOException, JsonProcessingException;
-
-  protected String getJSONAnnotation(final String string) {
-    return StringUtils.prependIfMissing(string, "@");
-  }
-
-  @Override
-  public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
-
-    version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null);
-    serverMode = (Boolean) ctxt.findInjectableValue(Boolean.class.getName(), null, null);
-
-    jsonType = version.getJSONMap().get(ODataServiceVersion.JSON_TYPE);
-    jsonId = version.getJSONMap().get(ODataServiceVersion.JSON_ID);
-    jsonETag = version.getJSONMap().get(ODataServiceVersion.JSON_ETAG);
-    jsonReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_READ_LINK);
-    jsonEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_EDIT_LINK);
-    jsonMediaReadLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAREAD_LINK);
-    jsonMediaEditLink = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK);
-    jsonMediaContentType = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_CONTENT_TYPE);
-    jsonMediaETag = version.getJSONMap().get(ODataServiceVersion.JSON_MEDIA_ETAG);
-    jsonAssociationLink = version.getJSONMap().get(ODataServiceVersion.JSON_ASSOCIATION_LINK);
-    jsonNavigationLink = version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK);
-    jsonCount = version.getJSONMap().get(ODataServiceVersion.JSON_COUNT);
-    jsonNextLink = version.getJSONMap().get(ODataServiceVersion.JSON_NEXT_LINK);
-    jsonDeltaLink = version.getJSONMap().get(ODataServiceVersion.JSON_DELTA_LINK);
-    jsonError = version.getJSONMap().get(ODataServiceVersion.JSON_ERROR);
-
-    return doDeserialize(jp, ctxt);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
deleted file mode 100644
index 944fb51..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-
-import java.io.IOException;
-import org.apache.olingo.commons.api.data.ResWrap;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public abstract class ODataJacksonSerializer<T> extends JsonSerializer<T> {
-
-  protected ODataServiceVersion version;
-
-  protected boolean serverMode;
-
-  protected abstract void doSerialize(T value, JsonGenerator jgen, SerializerProvider provider)
-          throws IOException, JsonProcessingException;
-
-  protected abstract void doContainerSerialize(ResWrap<T> value, JsonGenerator jgen, SerializerProvider provider)
-          throws IOException, JsonProcessingException;
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
-          throws IOException, JsonProcessingException {
-
-    version = (ODataServiceVersion) provider.getAttribute(ODataServiceVersion.class);
-    serverMode = (Boolean) provider.getAttribute(Boolean.class);
-
-    if (value instanceof ResWrap) {
-      doContainerSerialize((ResWrap) value, jgen, provider);
-    } else {
-      doSerialize(value, jgen, provider);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
new file mode 100755
index 0000000..9d9f35c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PropertyImpl.java
@@ -0,0 +1,63 @@
+/*
+ * 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.olingo.commons.core.data;
+
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.Value;
+
+public class PropertyImpl extends AbstractAnnotatedObject implements Property {
+
+  private static final long serialVersionUID = -7175704800169997060L;
+
+  private String name;
+
+  private String type;
+
+  private Value value;
+
+  @Override
+  public String getName() {
+    return name;
+  }
+
+  @Override
+  public void setName(final String name) {
+    this.name = name;
+  }
+
+  @Override
+  public String getType() {
+    return type;
+  }
+
+  @Override
+  public void setType(final String type) {
+    this.type = type;
+  }
+
+  @Override
+  public Value getValue() {
+    return value;
+  }
+
+  @Override
+  public void setValue(final Value value) {
+    this.value = value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/46a34178/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java
deleted file mode 100644
index 36cb682..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLODataErrorImpl.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.olingo.commons.core.data;
-
-public class XMLODataErrorImpl extends AbstractODataError {
-
-}