Skip to content

Commit

Permalink
some more improvements for serialization rules +
Browse files Browse the repository at this point in the history
update schema (optional elements are not required)
  • Loading branch information
BirgitBoss committed Apr 12, 2024
1 parent f2f225e commit 5a81a49
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ The following rules shall be adhered to when serializing a submodel, a submodel
** _Property_ is serialized as $\{Property/idShort}: $\{Property/value} where $\{Property/value} is the JSON serialization of the respective property’s value in accordance with the data type to value mapping (see table after this section).
** _MultiLanguageProperty_ is serialized as named JSON object with $\{MultiLanguageProperty/idShort} as the name of the containing JSON property. The JSON object contains an array of JSON objects for each language of the _MultiLanguageProperty_ with the language as name and the corresponding localized string as value of the respective JSON property. The language name is defined as two chars according to ISO 639-1.
** _Range_ is serialized as named JSON object with $\{Range/idShort} as the name of the containing JSON property. The JSON object contains two JSON properties. The first is named “min”. The second is named “max”. Their corresponding values are $\{Range/min} and $\{Range/max}.
** _File_ and _Blob_ are serialized as named JSON objects with $\{File/idShort} or $\{Blob/idShort}as the name of the containing JSON property. The JSON object contains two JSON properties. The first refers to the content type named $\{File/contentType} resp. $\{Blob/contentType}. The latter refers to the value named “value” $\{File/value} resp. $\{Blob/value}. The resulting ValueOnly object is indistinguishable whether it contains File or Blob attributes. Therefore, the receiver needs to take the type of the target resource into account. Since the receiver knows in advance if a File or a Blob SubmodelElement shall be manipulated, it can parse the transferred ValueOnly object accordingly as a File or Blob object.
** _File_ and _Blob_ are serialized as named JSON objects with $\{File/idShort} or $\{Blob/idShort}as the name of the containing JSON property. The JSON object contains two JSON properties. The first refers to the content type named $\{File/contentType} resp. $\{Blob/contentType}. The latter refers to the value named “value” $\{File/value} resp. $\{Blob/value}. The resulting ValueOnly object is indistinguishable whether it contains File or Blob attributes. Therefore, the receiver needs to take the type of the target resource into account. Since the receiver knows in advance if a File or a Blob SubmodelElement shall be manipulated, it can parse the transferred Value-Only object accordingly as a File or Blob object. For Blobs the value attribute is optional (in this case a Blob can be distinguished from a File).
** _SubmodelElementCollection_ is serialized as named JSON object with $\{SubmodelElementCollection/idShort} as the name of the containing JSON property. The elements contained within the struct are serialized according to their respective type with $\{SubmodelElement/idShort} as the name of the containing JSON property.
** _SubmodelElementList_ is serialized as a named JSON array with $\{SubmodelElementList/idShort} as the name of the containing JSON property. The elements in the JSON array are the ValueOnly serializations of the elements contained in the SubmodelElementList while preserving the order, i.e. index n in the JSON array is the ValueOnly serialization of the element at index n of the SubmodelElementList.
** _ReferenceElement_ is serialized as $\{ReferenceElement/idShort}: $\{ReferenceElement/value} where $\{ReferenceElement/value} is the serialization of the _Reference_ class in format "Normal".
** _RelationshipElement_ is serialized as named JSON object with $\{RelationshipElement/idShort} as the name of the containing JSON property. The JSON object contains two JSON properties. The first is named “first”. The second is named “second”. Their corresponding values are $\{RelationshipElement/first} resp. $\{Relationship/second}. The values are serialized according to the serialization of a _ReferenceElement_ (see above).
** _AnnotatedRelationshipElement_ is serialized according to the serialization of a _RelationshipElement_ (see above). Additionally, a third named JSON object is introduced with “annotations” as the name of the containing JSON property. The value is $\{AnnotatedRelationshipElement/annotations}. The values of the array items are serialized depending on the type of the annotation data element.
** _Entity_ is serialized as named JSON object with $\{Entity/idShort} as the name of the containing JSON property. The JSON object contains three JSON properties. The first is named “statements” $\{Entity/statements} and contains an array of the serialized submodel elements according to their respective serialization mentioned in this clause. The second is named either “globalAssetId” or “specificAssetId” and contains either a _Reference_ (see above) or a _SpecificAssetId_. The third property is named “entityType” and contains a string representation of $\{Entity/entityType}. _SpecificAssetId_ (as used in _Entity_) is serialized as named JSON object with three JSON properties named as the attributes of _SpecificAssetId._
** _AnnotatedRelationshipElement_ is serialized according to the serialization of a _RelationshipElement_ (see above). Additionally, a third named JSON object is introduced with “annotations” as the name of the containing JSON property. The value is $\{AnnotatedRelationshipElement/annotations}. The values of the array items are serialized depending on the type of the annotation data element. Annotations are optional.
** _Entity_ is serialized as named JSON object with $\{Entity/idShort} as the name of the containing JSON property. The JSON object contains four JSON properties. The first is named “statements” $\{Entity/statements} and contains an array of the serialized submodel elements according to their respective serialization mentioned in this clause. The second is named “globalAssetId” and the third “specificAssetIds”. Either a "globalAssetId" value or a "specificAssetIds" value shall exist. The other attributes are optional. “globalAssetId” corresponds to a _Reference_ (see above). _SpecificAssetIds" is an array of objects serializing _SpecificAssetId_. A single _SpecificAssetId_ in the array corresponds to the serialization of the _SpecificAssetId_ class in format "Normal". The forth property is named “entityType” and contains a string representation of $\{Entity/entityType}. Statements and the entityType are optional.
** _BasicEventElement_ is serialized as named JSON object with $\{BasicEventElement/idShort} as the name of the containing JSON property. The JSON object contains one JSON property named “observed” with the corresponding value of $\{BasicEventElement/observed} as the standard serialization of the _Reference_ class.


Expand All @@ -61,7 +61,9 @@ The following rules shall be adhered to when serializing a single submodel eleme
** _BasicEventElement_ is serialized as JSON object. The JSON object is serialized as described above.


* Submodel elements defined in the submodel other than the ones mentioned above are not subject to the Value-Only serialization.
Submodel elements defined in the submodel other than the ones mentioned above are not subject to the Value-Only serialization.

Optional elements (like for example globalAssetId for an Entity submodel element) with no value shall be omitted in the serialization.

*Data type to value mapping* footnote:[cf. https://openmanufacturingplatform.github.io/sds-documentation/bamm-specification/2.0.0/datatypes.html]

Expand Down Expand Up @@ -470,7 +472,6 @@ See Annex B for an example that validates against this schema.
"required": [
"first",
"second",
"annotation"
],
"additionalProperties": false
},
Expand Down Expand Up @@ -500,7 +501,6 @@ See Annex B for an example that validates against this schema.
},
"required": [
"contentType",
"value"
],
"additionalProperties": false
},
Expand Down Expand Up @@ -530,10 +530,6 @@ See Annex B for an example that validates against this schema.
}
}
},
"required": [
"statements",
"entityType"
],
"additionalProperties": false
},
"FileValue": {
Expand Down

0 comments on commit 5a81a49

Please sign in to comment.