Skip to content

[Enhancement]: When deserialising and then serialising a statement the objectType the value should be retained #201

Closed

Description

@thomasturrell

What

When deserialising and then serialising a statement the objectType the value should be retained.

This applies to all objects in a statement that have an objectType.

Deserialising and then serialising statement with an objectType :

final var json = """
    {
        "actor":{
            "name":"A N Other",
            "mbox":"mailto:another@example.com"
        },
        "verb":{
            "id":"http://adlnet.gov/expapi/verbs/attempted"
        },
        "object":{
            "objectType":"Activity",
            "id":"https://example.com/activity/simplestatement"
        }
    }""";

final var statement = objectMapper.readValue(json, Statement.class);

final var result = objectMapper.writeValueAsString(statement);

assertThat(result, hasJsonPath("$.object.objectType"));

Deserialising and then serialising statement without an objectType:

final var json = """
    {
        "actor":{
            "name":"A N Other",
            "mbox":"mailto:another@example.com"
        },
        "verb":{
            "id":"http://adlnet.gov/expapi/verbs/attempted"
        },
        "object":{
            "id":"https://example.com/activity/simplestatement"
        }
    }""";

final var statement = objectMapper.readValue(json, Statement.class);

final var result = objectMapper.writeValueAsString(statement);

assertThat(result, hasNoJsonPath("$.object.objectType"));

Why

An LRS is expected to return minimal and canonical versions of statements.

Minimal versions of a statement do not contain objectType.

Canonical versions of a statement should contain the objectType as originally sent to the LRS by the LRP.

It is worth noting that the objectType property is optional when it is not ambiguous. This creates a complication because it can not be assumed that the original statement contained the objectType property.

Notes

No response

Activity

  1. added a commit that references this issue on Aug 8, 2023
    8e58ff6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions