Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly document mapping of samm-c:Either to JSON payloads #279

Merged
merged 14 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/modules/ROOT/pages/modeling-guidelines.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ Aspects each containing a single Collection.
Describes a Property whose value can have one of two possible types (a disjoint union). This
Characteristic is special since it does not directly define a data type. The data type is defined in
the two Characteristics which define the left and right value of the disjoint union. Also see
xref:characteristics.adoc#either-characteristic[Either].
xref:characteristics.adoc#either-characteristic[Either] and xref:payload.adoc[Mapping to JSON].

Example:

Expand Down
43 changes: 42 additions & 1 deletion documentation/modules/ROOT/pages/payloads.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ the data. The mappings are described in the following table.
.2+| Encoded binary data
| `xsd:hexBinary` | String
| `xsd:base64Binary` | String
.3+| Miscellaneous types
.4+| Miscellaneous types
| `xsd:anyURI` | String
| `samm:curie` | String
| `rdf:langString`
| A JSON object with a structure as described in the rules above.
| `samm-c:Either` | A JSON object with the left field and the value, which is one of the types proposed in `xref:characteristics.adoc#either-characteristic[Either]`.
Yauhenikapl marked this conversation as resolved.
Show resolved Hide resolved
|===

For example, a Property `errorMessage` with effective data type `rdf:langString` and the value
Expand All @@ -174,6 +175,46 @@ A Property `errorMessages` with a Collection Characteristic and effective data t
}
----

Another one example for `samm-c:Either`, a Property `speedProperty` has Characteristic and effective data type `samm-c:Either` and the possible values
`isMoving` (`xref:datatypes.adoc#data-types[xsd:boolean]` data type) or '60' (`Number`) would be serialized in the JSON payload as follows:
Yauhenikapl marked this conversation as resolved.
Show resolved Hide resolved
[source,json]
----
{
"speedProperty": {
"left": true
}
}

or
Yauhenikapl marked this conversation as resolved.
Show resolved Hide resolved

{
"speedProperty": {
"left": 60
}
}
----

A Property `speedProperty` has Characteristic and effective data type `samm-c:Either`. Field `samm-c:left` has type `samm-c:Either` and field `samm-c:right` has type `xref:datatypes.adoc#data-types[xsd:boolean]`.
Yauhenikapl marked this conversation as resolved.
Show resolved Hide resolved
Field `samm-c:left` has possible values `isMoving` (`xref:datatypes.adoc#data-types[xsd:boolean]` data type) or '60' (`Number`). This structure would be serialized in the JSON payload as follows:
[source,json]
----
{
"speedProperty": {
"left": {
"left": 60
}
}
}

or

{
"speedProperty": {
"left": true
}
}
----


CAUTION: Due to the https://www.ecma-international.org/ecma-262/5.1/#sec-8.5[limits in the
Yauhenikapl marked this conversation as resolved.
Show resolved Hide resolved
represention of numbers] in JSON, the maximum integer number that can be used without losing
Expand Down
Loading