Author: fchrist
Date: Fri Sep 30 09:38:01 2011
New Revision: 1177566
URL: http://svn.apache.org/viewvc?rev=1177566&view=rev
Log:
STANBOL-221 Updated JSON-LD support according to spec 1.0
- New @context notation
- Support for namespaces and prefixes
- Type coercion
- Simple datatypes like integer
Added:
incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/format/NamespaceEnum.java
Modified:
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonComparator.java
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdParser.java
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdResource.java
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonSerializer.java
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdTest.java
incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java
incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java
incubator/stanbol/trunk/factstore/src/test/java/org/apache/stanbol/factstore/model/FactSchemaTest.java
incubator/stanbol/trunk/factstore/src/test/java/org/apache/stanbol/factstore/web/resource/FactsResourceTest.java
incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/factstore/FactStoreTest.java
Modified:
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonComparator.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonComparator.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonComparator.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonComparator.java
Fri Sep 30 09:38:01 2011
@@ -31,29 +31,33 @@ public class JsonComparator implements C
int value;
if (arg0.equals(arg1)) {
value = 0;
- } else if (arg0.equals("#")) {
+ } else if (arg0.equals(JsonLdCommon.CONTEXT)) {
value = -1;
- } else if (arg1.equals("#")) {
+ } else if (arg1.equals(JsonLdCommon.CONTEXT)) {
value = 1;
- } else if (arg0.equals("@")) {
- value = -1;
- } else if (arg1.equals("@")) {
+ } else if (arg0.equals(JsonLdCommon.COERCE)) {
value = 1;
- } else if (arg0.equals("a")) {
+ } else if (arg1.equals(JsonLdCommon.COERCE)) {
value = -1;
- } else if (arg1.equals("a")) {
+ } else if (arg0.equals(JsonLdCommon.TYPES)) {
value = 1;
- } else if (arg0.equals("#base")) {
+ } else if (arg1.equals(JsonLdCommon.TYPES)) {
+ value = -1;
+ } else if (arg0.equals(JsonLdCommon.SUBJECT)) {
value = -1;
- } else if (arg1.equals("#base")) {
+ } else if (arg1.equals(JsonLdCommon.SUBJECT)) {
value = 1;
- } else if (arg0.equals("#vocab")) {
+ } else if (arg0.equals(JsonLdCommon.TYPE)) {
value = -1;
- } else if (arg1.equals("#vocab")) {
+ } else if (arg1.equals(JsonLdCommon.TYPE)) {
value = 1;
- } else if (arg0.equals("#types")) {
+ } else if (arg0.equals(JsonLdCommon.DATATYPE)) {
+ value = 1;
+ } else if (arg1.equals(JsonLdCommon.DATATYPE)) {
+ value = -1;
+ } else if (arg0.equals(JsonLdCommon.LITERAL)) {
value = 1;
- } else if (arg1.equals("#types")) {
+ } else if (arg1.equals(JsonLdCommon.LITERAL)) {
value = -1;
} else {
value =
String.valueOf(arg0).toLowerCase().compareTo(String.valueOf(arg1).toLowerCase());
Modified:
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLd.java
Fri Sep 30 09:38:01 2011
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -47,9 +48,11 @@ public class JsonLd extends JsonLdCommon
/**
* Flag to control whether type coercion should be applied on
serialization. Default value is
- * <code>false</code>.
+ * <code>true</code>.
*/
- private boolean useTypeCoercion = false;
+ private boolean useTypeCoercion = true;
+
+
/**
* Adds the given resource to this JsonLd object using the resource's
subject as key. If the key is NULL
@@ -129,18 +132,6 @@ public class JsonLd extends JsonLdCommon
Map<String,Object> subjectObject = new
TreeMap<String,Object>(new JsonComparator());
JsonLdResource resource = resourceMap.get(subject);
- // put the namespaces
- if (!this.namespacePrefixMap.isEmpty() ||
this.useTypeCoercion) {
- Map<String,Object> nsObject = new
TreeMap<String,Object>(new JsonComparator());
- for (String ns : this.namespacePrefixMap.keySet()) {
- nsObject.put(this.namespacePrefixMap.get(ns), ns);
- }
- if (this.useTypeCoercion) {
- putCoercionTypes(nsObject, resource.getCoercionMap());
- }
- subjectObject.put("#", nsObject);
- }
-
// put subject
if (resource.getSubject() != null &&
!resource.getSubject().isEmpty()) {
subjectObject.put(SUBJECT,
handleCURIEs(resource.getSubject()));
@@ -159,8 +150,23 @@ public class JsonLd extends JsonLdCommon
// add to list of subjects
json.add(subjectObject);
- }
+
+ // put the used namespaces
+ if (!this.usedNamespaces.isEmpty() || this.useTypeCoercion) {
+ Map<String,Object> nsObject = new
TreeMap<String,Object>(new JsonComparator());
+ if (this.useTypeCoercion) {
+ putCoercedTypes(nsObject, resource.getCoerceMap());
+ }
+
+ for (String ns : this.usedNamespaces.keySet()) {
+ nsObject.put(this.usedNamespaces.get(ns), ns);
+ }
+ this.usedNamespaces.clear();
+
+ subjectObject.put(CONTEXT, nsObject);
+ }
+ }
}
return json;
@@ -194,7 +200,7 @@ public class JsonLd extends JsonLdCommon
putTypes(subjectObject, resource);
if (this.useTypeCoercion) {
- coercionMap.putAll(resource.getCoercionMap());
+ coercionMap.putAll(resource.getCoerceMap());
}
// put properties = objects
@@ -209,23 +215,24 @@ public class JsonLd extends JsonLdCommon
if (subjects.size() == 1) {
json = (Map<String,Object>) subjects.get(0);
} else {
- json.put("@", subjects);
+ json.put(SUBJECT, subjects);
}
}
}
// put the namespaces
- if (!this.namespacePrefixMap.isEmpty() || (!coercionMap.isEmpty() &&
this.useTypeCoercion)) {
-
+ if (!this.usedNamespaces.isEmpty() || (!coercionMap.isEmpty() &&
this.useTypeCoercion)) {
Map<String,Object> nsObject = new TreeMap<String,Object>(new
JsonComparator());
- for (String ns : namespacePrefixMap.keySet()) {
- nsObject.put(namespacePrefixMap.get(ns), ns);
- }
if (!coercionMap.isEmpty() && this.useTypeCoercion) {
- putCoercionTypes(nsObject, coercionMap);
+ putCoercedTypes(nsObject, coercionMap);
}
- json.put("#", nsObject);
+
+ for (String ns : usedNamespaces.keySet()) {
+ nsObject.put(usedNamespaces.get(ns), ns);
+ }
+
+ json.put(CONTEXT, nsObject);
}
return json;
@@ -238,7 +245,7 @@ public class JsonLd extends JsonLdCommon
types.add(handleCURIEs(type));
}
if (types.size() == 1) {
- subjectObject.put("a", types.get(0));
+ subjectObject.put(TYPE, types.get(0));
} else {
Collections.sort(types, new Comparator<String>() {
@@ -248,23 +255,30 @@ public class JsonLd extends JsonLdCommon
}
});
- subjectObject.put("a", types);
+ subjectObject.put(TYPE, types);
}
}
}
- private void putCoercionTypes(Map<String,Object> jsonObject,
Map<String,String> coercionMap) {
+ private void putCoercedTypes(Map<String,Object> jsonObject,
Map<String,String> coercionMap) {
if (!coercionMap.isEmpty()) {
- Map<String,String> nsCoercionMap = new TreeMap<String,String>(new
JsonComparator());
+ Map<String,List<String>> nsCoercionMap = new
TreeMap<String,List<String>>(new JsonComparator());
for (String property : coercionMap.keySet()) {
- nsCoercionMap.put(handleCURIEs(property),
handleCURIEs(coercionMap.get(property)));
+ String prop = handleCURIEs(property);
+ String type = handleCURIEs(coercionMap.get(property));
+
+ if (nsCoercionMap.get(type) == null) {
+ nsCoercionMap.put(type, new LinkedList<String>());
+ }
+ List<String> propList = nsCoercionMap.get(type);
+ propList.add(prop);
}
- jsonObject.put("#types", nsCoercionMap);
+ jsonObject.put(COERCE, nsCoercionMap);
}
}
private void putProperties(Map<String,Object> jsonObject, JsonLdResource
resource) {
- putProperties(jsonObject, resource.getPropertyMap(),
resource.getCoercionMap());
+ putProperties(jsonObject, resource.getPropertyMap(),
resource.getCoerceMap());
}
private void putProperties(Map<String,Object> outputObject,
@@ -272,6 +286,7 @@ public class JsonLd extends JsonLdCommon
Map<String,String> coercionMap) {
for (String property : inputMap.keySet()) {
Object value = inputMap.get(property);
+ value = convertValueType(value);
if (value instanceof String) {
String strValue = (String) value;
if (coercionMap != null) {
@@ -279,13 +294,19 @@ public class JsonLd extends JsonLdCommon
if (type != null) {
if (this.useTypeCoercion) {
strValue = (String)doCoerce(strValue, type);
+ outputObject.put(handleCURIEs(property),
handleCURIEs(strValue));
} else {
- strValue = unCoerce(strValue, type);
+ Object objValue = unCoerce(strValue, type);
+ outputObject.put(handleCURIEs(property), objValue);
}
}
+ else {
+ outputObject.put(handleCURIEs(property),
handleCURIEs(strValue));
+ }
+ }
+ else {
+ outputObject.put(handleCURIEs(property),
handleCURIEs(strValue));
}
- value = handleCURIEs(strValue);
- outputObject.put(handleCURIEs(property), value);
} else if (value instanceof Object[]) {
Object[] arrayValue = (Object[]) value;
putProperties(outputObject, property, arrayValue, coercionMap);
@@ -297,7 +318,7 @@ public class JsonLd extends JsonLdCommon
} else if (value instanceof JsonLdIRI) {
JsonLdIRI iriValue = (JsonLdIRI) value;
Map<String,Object> iriObject = new HashMap<String,Object>();
- iriObject.put("@iri", handleCURIEs(iriValue.getIRI()));
+ iriObject.put(IRI, handleCURIEs(iriValue.getIRI()));
outputObject.put(handleCURIEs(property), iriObject);
} else {
if (coercionMap != null) {
@@ -305,9 +326,9 @@ public class JsonLd extends JsonLdCommon
if (type != null) {
Object objValue = null;
if (this.useTypeCoercion) {
- objValue = doCoerce(value.toString(), type);
+ objValue = doCoerce(value, type);
} else {
- objValue = unCoerce(value.toString(), type);
+ objValue = unCoerce(value, type);
}
if (objValue instanceof String) {
@@ -331,65 +352,81 @@ public class JsonLd extends JsonLdCommon
String property,
Object[] arrayValue,
Map<String,String> coercionMap) {
- if (arrayValue instanceof String[]) {
- String[] stringArray = (String[]) arrayValue;
- List<String> valueList = new ArrayList<String>();
- for (String uri : stringArray) {
- valueList.add(handleCURIEs(uri));
- }
- outputObject.put(handleCURIEs(property), valueList);
- } else {
- List<Object> valueList = new ArrayList<Object>();
- for (Object object : arrayValue) {
- if (object instanceof Map<?,?>) {
- // The value of an array element is a Map. Handle maps
recursively.
- Map<String,Object> inputMap = (Map<String,Object>) object;
- Map<String,Object> subOutputObject = new
HashMap<String,Object>();
- valueList.add(subOutputObject);
- putProperties(subOutputObject, inputMap, coercionMap);
- } else if (object instanceof JsonLdIRI) {
- JsonLdIRI iriValue = (JsonLdIRI) object;
+
+ String type = null;
+ if (coercionMap != null && !this.useTypeCoercion) {
+ type = coercionMap.get(property);
+ }
+
+ List<Object> valueList = new ArrayList<Object>();
+ for (Object object : arrayValue) {
+ if (object instanceof Map<?,?>) {
+ // The value of an array element is a Map. Handle maps
recursively.
+ Map<String,Object> inputMap = (Map<String,Object>) object;
+ Map<String,Object> subOutputObject = new
HashMap<String,Object>();
+ valueList.add(subOutputObject);
+ putProperties(subOutputObject, inputMap, coercionMap);
+ } else if (object instanceof JsonLdIRI) {
+ JsonLdIRI iriValue = (JsonLdIRI) object;
+ if (this.useTypeCoercion) {
+ valueList.add(iriValue.getIRI());
+ } else {
Map<String,Object> iriObject = new
HashMap<String,Object>();
- iriObject.put("@iri", handleCURIEs(iriValue.getIRI()));
+ iriObject.put(IRI, handleCURIEs(iriValue.getIRI()));
valueList.add(iriObject);
+ }
+ } else if (object instanceof String) {
+ String strValue = (String) object;
+ if (type != null) {
+ valueList.add(unCoerce(handleCURIEs(strValue), type));
} else {
- // Don't know what it is - just add it
- valueList.add(object);
+ valueList.add(handleCURIEs(strValue));
}
+ } else {
+ // Don't know what it is - just add it
+ valueList.add(object);
}
-
- // Add the converted values
- outputObject.put(handleCURIEs(property), valueList);
}
+
+ // Add the converted values
+ outputObject.put(handleCURIEs(property), valueList);
}
/**
- * Appends the type to the Value if not present.
+ * Returns a map specifying the literal form and the datatype.
*
* @param strValue
* @param type
* @return
*/
- private String unCoerce(String strValue, String type) {
- String typeSuffix = "^^" + unCURIE((type));
- if (!strValue.endsWith(typeSuffix)) {
- strValue = "\"" + strValue + "\"^^<" + type + ">";
- }
- return strValue;
+ private Map<String, Object> unCoerce(Object value, String type) {
+ Map<String, Object> typeDef = new TreeMap<String,Object>(new
JsonComparator());
+
+ typeDef.put(LITERAL, String.valueOf(value));
+ typeDef.put(DATATYPE, handleCURIEs(type));
+
+ return typeDef;
}
/**
* Removes the type from the value and handles conversion to Integer and
Boolean.
*
+ * @FIXME Use @literal and @datatype notation when parsing typed literals
+ *
* @param strValue
* @param type
* @return
*/
- private Object doCoerce(String strValue, String type) {
- String typeSuffix = "^^" + unCURIE((type));
- strValue = strValue.replace(typeSuffix, "");
- strValue = strValue.replaceAll("\"", "");
- return convertValueType(strValue);
+ private Object doCoerce(Object value, String type) {
+ if (value instanceof String) {
+ String strValue = (String) value;
+ String typeSuffix = "^^" + unCURIE((type));
+ strValue = strValue.replace(typeSuffix, "");
+ strValue = strValue.replaceAll("\"", "");
+ return strValue;
+ }
+
+ return value;
}
/**
@@ -398,19 +435,30 @@ public class JsonLd extends JsonLdCommon
* @param strValue
* @return
*/
- private Object convertValueType(String strValue) {
- // check if value can be interpreted as integer
- try {
- return Integer.valueOf(strValue);
- }
- catch (Throwable t) {};
-
- // check if value can be interpreted as boolean
- if (strValue.equalsIgnoreCase("true") ||
strValue.equalsIgnoreCase("false")) {
- return Boolean.valueOf(strValue);
+ private Object convertValueType(Object value) {
+ if (value instanceof String) {
+ String strValue = (String) value;
+ // check if value can be interpreted as integer
+ try {
+ return Integer.valueOf(strValue);
+ }
+ catch (Throwable t) {};
+
+ // check if it is a float value
+ try {
+ return Float.valueOf(strValue);
+ }
+ catch (Throwable t) {};
+
+ // check if value can be interpreted as boolean
+ if (strValue.equalsIgnoreCase("true") ||
strValue.equalsIgnoreCase("false")) {
+ return Boolean.valueOf(strValue);
+ }
+
+ return strValue;
}
- return strValue;
+ return value;
}
/**
Modified:
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdCommon.java
Fri Sep 30 09:38:01 2011
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * 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.stanbol.commons.jsonld;
import java.util.HashMap;
@@ -22,13 +22,29 @@ import java.util.Map;
public abstract class JsonLdCommon {
public static final String CONTEXT = "@context";
- public static final String COERCION = "@coercion";
+ public static final String COERCE = "@coerce";
+
+ public static final String LITERAL = "@literal";
+ public static final String DATATYPE = "@datatype";
+
public static final String IRI = "@iri";
- public static final String PROFILE = "@profile";
- public static final String SUBJECT = "@";
- public static final String TYPES = "#types";
+ public static final String SUBJECT = "@subject";
+ public static final String TYPE = "@type";
+
+ public static final String PROFILE = "@profile";
+ public static final String TYPES = "@types";
+
+ /**
+ * Maps URIs to namespace prefixes.
+ */
protected Map<String,String> namespacePrefixMap = new
HashMap<String,String>();
+
+ /**
+ * Internal map to hold the namespaces and prefixes that were actually
used.
+ */
+ protected Map<String, String> usedNamespaces = new HashMap<String,
String>();
+
/**
* Flag to control whether the namespace prefix map should be used to
shorten URIs to CURIEs during
* serialization. Default value is <code>true</code>.
@@ -65,7 +81,7 @@ public abstract class JsonLdCommon {
public void addNamespacePrefix(String namespace, String prefix) {
namespacePrefixMap.put(namespace, prefix);
}
-
+
/**
* Flag to control whether the namespace prefix map should be used to
shorten IRIs to prefix notation
* during serialization. Default value is <code>true</code>.
@@ -89,7 +105,7 @@ public abstract class JsonLdCommon {
public void setApplyNamespaces(boolean applyNamespaces) {
this.applyNamespaces = applyNamespaces;
}
-
+
/**
* Convert URI to CURIE if namespaces should be applied and CURIEs to URIs
if namespaces should not be
* applied.
@@ -109,23 +125,39 @@ public abstract class JsonLdCommon {
}
public String doCURIE(String uri) {
+ String curie = uri;
if (uri != null) {
for (String namespace : namespacePrefixMap.keySet()) {
- String prefix = namespacePrefixMap.get(namespace) + ":";
+ String prefix = namespacePrefixMap.get(namespace);
+ String prefixEx = prefix + ":";
+
if (!uri.startsWith(prefix)) {
- uri = uri.replace(namespace, prefix);
+ curie = curie.replace(namespace, prefixEx);
+
+ if (!uri.equals(curie)) {
+ // we mark this namespace as being used
+ this.usedNamespaces.put(namespace, prefix);
+ break;
+ }
+ }
+ else {
+ // we mark this namespace as being used
+ this.usedNamespaces.put(namespace, prefix);
+ break;
}
}
}
- return uri;
+ return curie;
}
public String unCURIE(String uri) {
if (uri != null) {
for (String namespace : namespacePrefixMap.keySet()) {
- String prefix = namespacePrefixMap.get(namespace) + ":";
- if (uri.startsWith(prefix)) {
- uri = uri.replace(prefix, namespace);
+ String prefix = namespacePrefixMap.get(namespace);
+ String prefixEx = prefix + ":";
+
+ if (uri.startsWith(prefixEx)) {
+ uri = uri.replace(prefixEx, namespace);
}
}
}
Modified:
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdParser.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdParser.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdParser.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdParser.java
Fri Sep 30 09:38:01 2011
@@ -79,12 +79,12 @@ public class JsonLdParser extends JsonLd
JSONObject context =
jo.getJSONObject(JsonLdCommon.CONTEXT);
for (int i = 0; i < context.names().length();
i++) {
String name =
context.names().getString(i).toLowerCase();
- if (name.equals(JsonLdCommon.TYPES)) {
+ if (name.equals(JsonLdCommon.COERCE)) {
JSONObject typeObject =
context.getJSONObject(name);
for (int j = 0; j <
typeObject.names().length(); j++) {
String property =
typeObject.names().getString(j);
String type =
typeObject.getString(property);
-
subject.putCoercionType(property, type);
+
subject.putPropertyType(property, type);
}
} else {
jld.addNamespacePrefix(context.getString(name), name);
Modified:
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdResource.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdResource.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdResource.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonLdResource.java
Fri Sep 30 09:38:01 2011
@@ -31,7 +31,11 @@ public class JsonLdResource {
private String subject;
private String profile;
private List<String> types = new ArrayList<String>();
- private Map<String,String> coercionMap = new HashMap<String,String>();
+
+ // maps properties to types
+ private Map<String,String> coerceMap = new HashMap<String,String>();
+
+ // maps properties to values
private Map<String,Object> propertyMap = new HashMap<String,Object>();
public String getSubject() {
@@ -58,16 +62,16 @@ public class JsonLdResource {
this.types.addAll(types);
}
- public void putCoercionType(String property, String type) {
- this.coercionMap.put(property, type);
+ public void putPropertyType(String property, String type) {
+ this.coerceMap.put(property, type);
}
- public String getCoercionTypeOf(String property) {
- return this.coercionMap.get(property);
+ public String getTypeOfProperty(String property) {
+ return this.coerceMap.get(property);
}
- public Map<String,String> getCoercionMap() {
- return this.coercionMap;
+ public Map<String,String> getCoerceMap() {
+ return this.coerceMap;
}
public List<String> getTypes() {
Modified:
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonSerializer.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonSerializer.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonSerializer.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/main/java/org/apache/stanbol/commons/jsonld/JsonSerializer.java
Fri Sep 30 09:38:01 2011
@@ -16,9 +16,13 @@
*/
package org.apache.stanbol.commons.jsonld;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+
/**
* Class to serialize a JSON object structure whereby the JSON structure is
defined by the basic data types
* Map and List.
@@ -97,9 +101,27 @@ public class JsonSerializer {
appendJsonMap(mapValue, sb, indent, level);
} else if (object instanceof List<?>) {
List<Object> lstValue = (List<Object>) object;
- appendList(lstValue, sb, indent, level);
- sb.append(',');
- appendLinefeed(sb, indent);
+ if (lstValue.size() == 1) {
+ // if the list contains only 1 element, we can serialize it as
a single value
+ appendValueOf(lstValue.get(0), sb, indent, level);
+ }
+ else {
+ // the list has more or no elements
+ appendList(lstValue, sb, indent, level);
+ sb.append(',');
+ appendLinefeed(sb, indent);
+ }
+ } else if (object instanceof JSONArray) {
+ JSONArray ja = (JSONArray) object;
+ List<Object> jsonList = new ArrayList<Object>();
+ try {
+ for (int i = 0; i < ja.length(); i++) {
+ jsonList.add(ja.get(i));
+ }
+ } catch (JSONException e) {
+ // ignore
+ }
+ appendValueOf(jsonList, sb, indent, level);
} else {
sb.append(object.toString());
sb.append(',');
@@ -130,10 +152,10 @@ public class JsonSerializer {
sb.append('\\');
sb.append(ch);
break;
- case '/':
- sb.append('\\');
- sb.append(ch);
- break;
+// case '/':
+// sb.append('\\');
+// sb.append(ch);
+// break;
case '\b':
sb.append("\\b");
break;
Modified:
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdParserTest.java
Fri Sep 30 09:38:01 2011
@@ -30,42 +30,42 @@ public class JsonLdParserTest {
jsonLd.setUseTypeCoercion(true);
String actual = jsonLd.toString();
- String expected =
"{\"#\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"upb\":\"http:\\/\\/upb.de\\/persons\\/\"},\"@\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}}";
+ String expected =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}}";
assertEquals(expected, actual);
assertNotNull(jsonLd);
}
@Test
public void testParse3() throws Exception {
- String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:employeeOf\",\"@\":[{\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"person\":{\"@iri\":\"upb:fchrist\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}}]}";
+ String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:employeeOf\",\"@subject\":[{\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"person\":{\"@iri\":\"upb:fchrist\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}}]}";
JsonLd jsonLd = JsonLdParser.parse(jsonldInput);
jsonLd.setUseTypeCoercion(true);
jsonLd.setApplyNamespaces(false);
String actual = jsonLd.toString();
- String expected =
"{\"#\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"upb\":\"http:\\/\\/upb.de\\/persons\\/\"},\"@\":[{\"@\":\"_:bnode1\",\"@profile\":\"http:\\/\\/iks-project.eu\\/ont\\/employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"http:\\/\\/upb.de\\/persons\\/bnagel\"}},{\"@\":\"_:bnode2\",\"@profile\":\"http:\\/\\/iks-project.eu\\/ont\\/employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"http:\\/\\/upb.de\\/persons\\/fchrist\"}}]}";
+ String expected =
"{\"@subject\":[{\"@subject\":\"_:bnode1\",\"@profile\":\"http://iks-project.eu/ont/employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"http://upb.de/persons/bnagel\"}},{\"@subject\":\"_:bnode2\",\"@profile\":\"http://iks-project.eu/ont/employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"http://upb.de/persons/fchrist\"}}]}";
assertEquals(expected, actual);
assertNotNull(jsonLd);
}
@Test
public void testParse4() throws Exception {
- String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:employeeOf\",\"@\":[{\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"person\":{\"@iri\":\"upb:fchrist\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}}]}";
+ String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:employeeOf\",\"@subject\":[{\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"person\":{\"@iri\":\"upb:fchrist\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}}]}";
JsonLd jsonLd = JsonLdParser.parse(jsonldInput);
jsonLd.setUseTypeCoercion(true);
jsonLd.setApplyNamespaces(true);
String actual = jsonLd.toString();
- String expected =
"{\"#\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"upb\":\"http:\\/\\/upb.de\\/persons\\/\"},\"@\":[{\"@\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@\":\"_:bnode2\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:fchrist\"}}]}";
+ String expected =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@subject\":\"_:bnode2\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:fchrist\"}}]}";
assertEquals(expected, actual);
assertNotNull(jsonLd);
}
@Test
public void testParse5() throws Exception {
- String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:employeeOf\",\"@\":[{\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"person\":{\"@iri\":\"upb:fchrist\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}}]}";
+ String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:employeeOf\",\"@subject\":[{\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"person\":{\"@iri\":\"upb:fchrist\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}}]}";
JsonLd jsonLd = JsonLdParser.parse(jsonldInput);
jsonLd.setUseTypeCoercion(true);
@@ -73,14 +73,14 @@ public class JsonLdParserTest {
jsonLd.setUseJointGraphs(false);
String actual = jsonLd.toString();
- String expected =
"[{\"#\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"upb\":\"http:\\/\\/upb.de\\/persons\\/\"},\"@\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"#\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"upb\":\"http:\\/\\/upb.de\\/persons\\/\"},\"@\":\"_:bnode2\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:fchrist\"}}]";
+ String expected =
"[{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":\"_:bnode2\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:fchrist\"}}]";
assertEquals(expected, actual);
assertNotNull(jsonLd);
}
@Test
public void testParse6() throws Exception {
- String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@\":[{\"@profile\":\"iks:employeeOf\",\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"@profile\":\"iks:friendOf\",\"person\":{\"@iri\":\"upb:bnagel\"},\"friend\":{\"@iri\":\"upb:fchrist\"}}]}";
+ String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":[{\"@profile\":\"iks:employeeOf\",\"person\":{\"@iri\":\"upb:bnagel\"},\"organization\":{\"@iri\":\"http://uni-paderborn.de\"}},{\"@profile\":\"iks:friendOf\",\"person\":{\"@iri\":\"upb:bnagel\"},\"friend\":{\"@iri\":\"upb:fchrist\"}}]}";
JsonLd jsonLd = JsonLdParser.parse(jsonldInput);
jsonLd.setUseTypeCoercion(true);
@@ -88,7 +88,7 @@ public class JsonLdParserTest {
jsonLd.setUseJointGraphs(true);
String actual = jsonLd.toString();
- String expected =
"{\"#\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"upb\":\"http:\\/\\/upb.de\\/persons\\/\"},\"@\":[{\"@\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http:\\/\\/uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@\":\"_:bnode2\",\"@profile\":\"iks:friendOf\",\"friend\":{\"@iri\":\"upb:fchrist\"},\"person\":{\"@iri\":\"upb:bnagel\"}}]}";
+ String expected =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@subject\":[{\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":{\"@iri\":\"http://uni-paderborn.de\"},\"person\":{\"@iri\":\"upb:bnagel\"}},{\"@subject\":\"_:bnode2\",\"@profile\":\"iks:friendOf\",\"friend\":{\"@iri\":\"upb:fchrist\"},\"person\":{\"@iri\":\"upb:bnagel\"}}]}";
assertEquals(expected, actual);
assertNotNull(jsonLd);
}
@@ -103,7 +103,7 @@ public class JsonLdParserTest {
jsonLd.setUseJointGraphs(true);
String actual = jsonLd.toString();
- String expected =
"{\"#\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"upb\":\"http:\\/\\/upb.de\\/persons\\/\"},\"@\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":\"UniPaderborn\",\"person\":\"Benjamin\"}";
+ String expected =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\"},\"@subject\":\"_:bnode1\",\"@profile\":\"iks:employeeOf\",\"organization\":\"UniPaderborn\",\"person\":\"Benjamin\"}";
assertEquals(expected, actual);
assertNotNull(jsonLd);
}
Modified:
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileParserTest.java
Fri Sep 30 09:38:01 2011
@@ -26,24 +26,25 @@ public class JsonLdProfileParserTest {
@Test
public void testParseProfile() throws Exception {
- String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"#types\":{\"person\":\"iks:person\",\"organization\":\"iks:organization\"}}}";
+ String jsonldInput =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"person\":\"iks:person\",\"organization\":\"iks:organization\"}}}";
JsonLdProfile profile = JsonLdProfileParser.parseProfile(jsonldInput);
String actual = profile.toString();
- String expected =
"{\"@context\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"#types\":{\"organization\":\"iks:organization\",\"person\":\"iks:person\"}}}";
+ String expected =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"organization\":\"iks:organization\",\"person\":\"iks:person\"}}}";
assertEquals(expected, actual);
assertNotNull(profile);
}
@Test
public void testParseProfileMultiType() throws Exception {
- String jsonldInput =
"{\"@context\":{\"#types\":{\"organization\":\"http:\\/\\/iks-project.eu\\/ont\\/organization\",\"person\":[\"http:\\/\\/iks-project.eu\\/ont\\/person\",\"http:\\/\\/www.schema.org\\/Person\"]}}}";
+ String jsonldInput =
"{\"@context\":{\"@types\":{\"organization\":\"http://iks-project.eu/ont/organization\",\"person\":[\"http://iks-project.eu/ont/person\",\"http://www.schema.org/Person\"]}}}";
JsonLdProfile profile = JsonLdProfileParser.parseProfile(jsonldInput);
- String expected =
"{\"@context\":{\"#types\":{\"organization\":\"http:\\/\\/iks-project.eu\\/ont\\/organization\",\"person\":[\"http:\\/\\/iks-project.eu\\/ont\\/person\",\"http:\\/\\/www.schema.org\\/Person\"]}}}";
+ String expected =
"{\"@context\":{\"@types\":{\"organization\":\"http://iks-project.eu/ont/organization\",\"person\":[\"http://iks-project.eu/ont/person\",\"http://www.schema.org/Person\"]}}}";
String actual = profile.toString();
+ toConsole(actual);
assertEquals(expected, actual);
assertNotNull(profile);
}
Modified:
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java?rev=1177566&r1=1177565&r2=1177566&view=diff
==============================================================================
---
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java
(original)
+++
incubator/stanbol/trunk/commons/jsonld/src/test/java/org/apache/stanbol/commons/jsonld/JsonLdProfileTest.java
Fri Sep 30 09:38:01 2011
@@ -32,7 +32,7 @@ public class JsonLdProfileTest {
profile.addType("organization", "iks:organization");
String actual = profile.toString();
- String expected =
"{\"@context\":{\"iks\":\"http:\\/\\/iks-project.eu\\/ont\\/\",\"#types\":{\"organization\":\"iks:organization\",\"person\":\"iks:person\"}}}";
+ String expected =
"{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"organization\":\"iks:organization\",\"person\":\"iks:person\"}}}";
assertEquals(expected, actual);
}
@@ -44,7 +44,7 @@ public class JsonLdProfileTest {
profile.addType("organization",
"http://iks-project.eu/ont/organization");
String actual = profile.toString();
- String expected =
"{\"@context\":{\"#types\":{\"organization\":\"http:\\/\\/iks-project.eu\\/ont\\/organization\",\"person\":\"http:\\/\\/iks-project.eu\\/ont\\/person\"}}}";
+ String expected =
"{\"@context\":{\"@types\":{\"organization\":\"http://iks-project.eu/ont/organization\",\"person\":\"http://iks-project.eu/ont/person\"}}}";
assertEquals(expected, actual);
}
@@ -57,7 +57,7 @@ public class JsonLdProfileTest {
profile.addType("organization",
"http://iks-project.eu/ont/organization");
String actual = profile.toString(0);
- String expected =
"{\"@context\":{\"#types\":{\"organization\":\"http:\\/\\/iks-project.eu\\/ont\\/organization\",\"person\":[\"http:\\/\\/iks-project.eu\\/ont\\/person\",\"http:\\/\\/www.schema.org\\/Person\"]}}}";
+ String expected =
"{\"@context\":{\"@types\":{\"organization\":\"http://iks-project.eu/ont/organization\",\"person\":[\"http://iks-project.eu/ont/person\",\"http://www.schema.org/Person\"]}}}";
assertEquals(expected, actual);
}