diff --git a/src/main/java/foundation/identity/jsonld/JsonLDKeywords.java b/src/main/java/foundation/identity/jsonld/JsonLDKeywords.java index da47820..6bab563 100644 --- a/src/main/java/foundation/identity/jsonld/JsonLDKeywords.java +++ b/src/main/java/foundation/identity/jsonld/JsonLDKeywords.java @@ -2,6 +2,8 @@ public class JsonLDKeywords { + public static final String JSONLD_TERM_AT_ID = "@id"; public static final String JSONLD_TERM_ID = "id"; + public static final String JSONLD_TERM_AT_TYPE = "@type"; public static final String JSONLD_TERM_TYPE = "type"; } diff --git a/src/main/java/foundation/identity/jsonld/JsonLDObject.java b/src/main/java/foundation/identity/jsonld/JsonLDObject.java index c4fde1c..d190018 100644 --- a/src/main/java/foundation/identity/jsonld/JsonLDObject.java +++ b/src/main/java/foundation/identity/jsonld/JsonLDObject.java @@ -275,19 +275,27 @@ public List getContexts() { } public final List getTypes() { - return JsonLDUtils.jsonLdGetStringList(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_TYPE); + List result = JsonLDUtils.jsonLdGetStringList(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_AT_TYPE); + if (result == null) result = JsonLDUtils.jsonLdGetStringList(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_TYPE); + return result; } public final String getType() { - return JsonLDUtils.jsonLdGetString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_TYPE); + String result = JsonLDUtils.jsonLdGetString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_AT_TYPE); + if (result == null) result = JsonLDUtils.jsonLdGetString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_TYPE); + return result; } public final boolean isType(String type) { - return JsonLDUtils.jsonLdContainsString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_TYPE, type); + boolean result = JsonLDUtils.jsonLdContainsString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_AT_TYPE, type); + if (! result) result = JsonLDUtils.jsonLdContainsString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_TYPE, type); + return result; } public final URI getId() { - return JsonLDUtils.stringToUri(JsonLDUtils.jsonLdGetString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_ID)); + URI result = JsonLDUtils.stringToUri(JsonLDUtils.jsonLdGetString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_AT_ID)); + if (result == null) result = JsonLDUtils.stringToUri(JsonLDUtils.jsonLdGetString(this.getJsonObject(), JsonLDKeywords.JSONLD_TERM_ID)); + return result; } /*