Skip to content

ReferenceId vs [JsonProperty(IsReference = true)] vs object #222

Open

Description

@JasonRoesbeke

When should an ADAPT object be referenced with the integer of the ReferenceId and when should it be the object? e.g: https://github.com/ADAPT/ADAPT/blob/7474401491a63c8268b2cd9b2749dbb800595736/source/ADAPT/LoggedData/LoggedData.cs#L60

&

https://github.com/ADAPT/ADAPT/blob/876407a8db7372586efd2baa2dd688518fd4853d/source/ADAPT/Equipment/EquipmentConfigurationGroup.cs#L31

Currently I get the feeling that we could reduce the size of the serialized data a lot when references are not the object but the integer.
E.g. using a serializer such as the JsonSerializer from Newtonsoft.Json, by default it will serialize all objects it encounters by value, thus the EquipmentConfigurationGroup with the list of EquipmentConfigurations in full multiple times instead of only writing a reference to a fully serialized object that is then the only fully serialized object in the Json file.

OR:

(For Newtonsoft.Json library:)
We could add [JsonProperty(IsReference = true)] to each property that is a reference so to not break the data model or setting the PreserveReferencesHandling of the JsonSerializer to objects.
But this would add a new kind of reference "$id" & "$ref" what I do not want (I'm using another reference format).
See: newtonsoft documentation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions