diff --git a/src/main/java/cz/cvut/kbss/jsonld/common/BeanAnnotationProcessor.java b/src/main/java/cz/cvut/kbss/jsonld/common/BeanAnnotationProcessor.java index f6413d5..0ed7b93 100644 --- a/src/main/java/cz/cvut/kbss/jsonld/common/BeanAnnotationProcessor.java +++ b/src/main/java/cz/cvut/kbss/jsonld/common/BeanAnnotationProcessor.java @@ -213,7 +213,10 @@ private static List getMarshallableFields(Class cls, Predicate } } } - return new ArrayList<>(fields); + final List result = new ArrayList<>(fields); + // Move object properties to the end + result.sort(Comparator.comparing(BeanAnnotationProcessor::isObjectProperty)); + return result; } /** diff --git a/src/test/java/cz/cvut/kbss/jsonld/serialization/ContextBuildingJsonLdSerializerTest.java b/src/test/java/cz/cvut/kbss/jsonld/serialization/ContextBuildingJsonLdSerializerTest.java index edfdda4..7da0b0b 100644 --- a/src/test/java/cz/cvut/kbss/jsonld/serialization/ContextBuildingJsonLdSerializerTest.java +++ b/src/test/java/cz/cvut/kbss/jsonld/serialization/ContextBuildingJsonLdSerializerTest.java @@ -231,12 +231,9 @@ void serializationCreatesEmbeddedContextToOverrideIncompatibleTermMapping() thro assertInstanceOf(Map.class, json.get(JsonLd.CONTEXT)); final Map context = (Map) json.get(JsonLd.CONTEXT); assertEquals(DC.Terms.TITLE, context.get("name")); - assertThat(json, hasKey(JsonLd.GRAPH)); - assertInstanceOf(Map.class, json.get(JsonLd.GRAPH)); - final Map study = (Map) json.get(JsonLd.GRAPH); - assertThat(study, hasKey("organization")); - assertInstanceOf(Map.class, study.get("organization")); - final Map organization = (Map) study.get("organization"); + assertThat(json, hasKey("organization")); + assertInstanceOf(Map.class, json.get("organization")); + final Map organization = (Map) json.get("organization"); assertThat(organization, hasKey(JsonLd.CONTEXT)); assertInstanceOf(Map.class, organization.get(JsonLd.CONTEXT)); final Map embeddedCtx = (Map) organization.get(JsonLd.CONTEXT);