Skip to content

Commit

Permalink
Chapter 7
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfhandl committed Jul 24, 2023
1 parent a1c731f commit 91421ae
Show file tree
Hide file tree
Showing 8 changed files with 750 additions and 517 deletions.
194 changes: 143 additions & 51 deletions docs/odata-json-format/odata-json-format.html

Large diffs are not rendered by default.

288 changes: 237 additions & 51 deletions docs/odata-json-format/odata-json-format.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions odata-json-format/4 Common Characteristics.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ parts. It contains OData values as part of a larger document. Requests
and responses are structured almost identical; the few existing
differences will be explicitly called out in the respective subsections.

# ##subsec Header Content-Type
## ##subsec Header Content-Type

Requests and responses with a JSON message body MUST have a
`Content-Type` header value of `application/json`.
Expand All @@ -31,7 +31,7 @@ Requests and responses MAY add the `streaming` parameter with
a value of `true` or `false`, see section [Payload
Ordering Constraints](#PayloadOrderingConstraints).

# ##subsec Message Body
## ##subsec Message Body

Each message body is represented as a single JSON object. This object is
either the representation of an [entity](#Entity),
Expand All @@ -48,7 +48,7 @@ result](#DeltaPayload).
Client libraries MUST retain the
order of objects within an array in JSON responses.

# ##subsec Relative URLs
## ##subsec Relative URLs

URLs present in a payload (whether request or response) MAY be
represented as relative URLs.
Expand Down Expand Up @@ -113,7 +113,7 @@ The resulting absolute URLs are
`http://host/service/Customers('ALFKI')` and
`http://host/service/Customers('ALFKI')/Orders`.

# ##subsec Payload Ordering Constraints
## ##subsec Payload Ordering Constraints

Ordering constraints MAY be imposed on the JSON payload in order to
support streaming scenarios. These ordering constraints MUST only be
Expand Down Expand Up @@ -185,7 +185,7 @@ Note that in OData 4.0 the `streaming` format parameter was prefixed with
`OData-Version `header equal to `4.01` or greater SHOULD NOT
include the `odata.` prefix.

# ##subsec Control Information
## ##subsec Control Information

In addition to the "pure data" a message body MAY contain
[annotations](#InstanceAnnotations) and control information that is
Expand All @@ -204,7 +204,7 @@ Receivers that encounter unknown
annotations in any namespace or unknown control information MUST NOT
stop processing and MUST NOT signal an error.

# ##subsubsec Control Information: `context` (`odata.context`)
### ##subsubsec Control Information: `context` (`odata.context`)

The `context` control information
returns the context URL (see [OData-Protocol](#ODataProtocol)) for the
Expand Down Expand Up @@ -238,7 +238,7 @@ Example ##ex:
```
:::

# ##subsubsec Control Information: `metadataEtag` (`odata.metadataEtag`)
### ##subsubsec Control Information: `metadataEtag` (`odata.metadataEtag`)

The `metadataEtag` control information MAY appear in a
response in order to specify the entity tag (ETag) that can be used to
Expand All @@ -255,7 +255,7 @@ in any responses.

For details on how ETags are used, see [OData-Protocol](#ODataProtocol).

# ##subsubsec Control Information: `type` (`odata.type`)
### ##subsubsec Control Information: `type` (`odata.type`)

The `type` control information specifies the type of a JSON
object or name/value pair. Its value is a URI that identifies the type
Expand Down Expand Up @@ -356,7 +356,7 @@ service
```
:::

# ##subsubsec Control Information: `count` (`odata.count`)
### ##subsubsec Control Information: `count` (`odata.count`)

The `count` control information occurs only in responses and
can annotate any collection, see [OData-Protocol](#ODataProtocol)
Expand All @@ -365,7 +365,7 @@ section 11.2.5.5 System Query Option
`Edm.Int64` value corresponding to
the total count of members in the collection represented by the request.

# ##subsubsec Control Information: `nextLink` (`odata.nextLink`)
### ##subsubsec Control Information: `nextLink` (`odata.nextLink`)

The `nextLink` control information indicates that a response
is only a subset of the requested collection. It contains a URL that
Expand All @@ -374,14 +374,14 @@ allows retrieving the next subset of the requested collection.
This control information can also be applied to [expanded to-many
navigation properties](#ExpandedNavigationProperty).

# ##subsubsec Control Information: `delta` (`odata.delta`)
### ##subsubsec Control Information: `delta` (`odata.delta`)

The `delta` control information is applied to a
collection-valued navigation property within an [added/changed
entity](#AddedChangedEntity) in a delta payload to represent changes
in membership or value of nested entities.

# ##subsubsec Control Information: `deltaLink` (`odata.deltaLink`)
### ##subsubsec Control Information: `deltaLink` (`odata.deltaLink`)

The `deltaLink` control information contains a URL that can
be used to retrieve changes to the current set of results. The
Expand All @@ -391,7 +391,7 @@ page of results. A page of results MUST NOT have both a
[`nextLink`](#ControlInformationnextLinkodatanextLink)
control information.

# ##subsubsec Control Information: `id` (`odata.id`)
### ##subsubsec Control Information: `id` (`odata.id`)

The `id` control information contains the entity-id, see
[OData-Protocol](#ODataProtocol). By convention the entity-id is
Expand Down Expand Up @@ -433,7 +433,7 @@ compared to other entities, reread, or updated. If
is specified and the `id` is not present in the entity, then
the canonical URL MUST be used as the entity-id.

# ##subsubsec Control Information: `editLink` and `readLink` (`odata.editLink` and `odata.readLink`)
### ##subsubsec Control Information: `editLink` and `readLink` (`odata.editLink` and `odata.readLink`)

The `[editLink`]{#odataEditLink} control information contains
the edit URL of the entity; see [OData-Protocol](#ODataProtocol).
Expand Down Expand Up @@ -485,7 +485,7 @@ For collections:
meaning in this context is reserved for future versions of this
specification.

# ##subsubsec Control Information: `etag` (`odata.etag`)
### ##subsubsec Control Information: `etag` (`odata.etag`)

The `etag` control information MAY be applied to an
[entity](#Entity) or collection in a response. The
Expand All @@ -499,7 +499,7 @@ The `etag` control information is ignored in request payloads for
single entities and not written in responses if
[`metadata=none`](#metadatanoneodatametadatanone) is requested.

# ##subsubsec Control Information: `navigationLink` and `associationLink` (`odata.navigationLink` and `odata.associationLink`)
### ##subsubsec Control Information: `navigationLink` and `associationLink` (`odata.navigationLink` and `odata.associationLink`)

The [`navigationLink`]{#odataNavigationLink} control information in a
response contains a _navigation URL_ that can be used to retrieve an
Expand Down Expand Up @@ -528,7 +528,7 @@ The `navigationLink` and `associationLink` control
information is ignored in request payloads and not written in responses
if [`metadata=none`](#metadatanoneodatametadatanone) is requested.

# ##subsubsec Control Information: `media*` (`odata.media*`)
### ##subsubsec Control Information: `media*` (`odata.media*`)

For [media entities](#MediaEntity) and [stream
properties](#StreamProperty) at least one of the control information
Expand Down Expand Up @@ -594,13 +594,13 @@ Example ##ex:
```
:::

# ##subsubsec Control Information: `removed` (`odata.removed`)
### ##subsubsec Control Information: `removed` (`odata.removed`)

The `removed` control information is used in [delta
payloads](#DeletedEntity) and indicates that the represented entity
is (to be) deleted.

# ##subsubsec Control Information: `collectionAnnotations` (`odata.collectionAnnotations`)
### ##subsubsec Control Information: `collectionAnnotations` (`odata.collectionAnnotations`)

The `collectionAnnotations` control information can be
applied to a collection containing primitive members in order to
Expand Down
197 changes: 197 additions & 0 deletions odata-json-format/7 Structural Property.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
-------

# ##sec Structural Property

A property within an entity or complex type instance is represented as a
name/value pair. The name MUST be the name of the property; the value is
represented depending on its type as a [primitive value](#PrimitiveValue),
a [complex value](#ComplexValue), a
[collection of primitive values](#CollectionofPrimitiveValues), or
a [collection of complex values](#CollectionofComplexValues).

## ##subsec Primitive Value

Primitive values are represented following the rules of
[RFC8259](#rfc8259).

Null values are represented as the JSON literal `null`.

Values of type `Edm.Boolean` are represented as the JSON
literals `true` and `false`

Values of types `Edm.Byte`, `Edm.SByte`,
`Edm.Int16`, `Edm.Int32`, `Edm.Int64`,
`Edm.Single`, `Edm.Double`, and
`Edm.Decimal` are represented as JSON numbers, except for
`-INF`, `INF`, and `NaN` which are
represented as strings.

Values of type `Edm.String` are represented as JSON strings,
using the JSON string escaping rules.

Values of type `Edm.Binary`, `Edm.Date`,
`Edm.DateTimeOffset`, `Edm.Duration`,
`Edm.Guid`, and `Edm.TimeOfDay` are represented as
JSON strings whose content satisfies the rules `binaryValue`,
`dateValue`, `dateTimeOffsetValue`,
`durationValue`, `guidValue`, and
`timeOfDayValue` respectively, in
[OData-ABNF](#ODataABNF).

Primitive values that cannot be represented, for example due to server
conversion issues or IEEE754 limitations on the size of an `Edm.Int64` or `Edm.Decimal` value, are
annotated with the `Core.ValueException` term. In this case,
the payload MAY include an approximation of the value and MAY specify a
string representation of the exact value in the `value`
property of the annotation.

Enumeration values are represented as JSON strings whose content
satisfies the rule `enumValue` in
[OData-ABNF](#ODataABNF). The preferred representation is the
`enumerationMember`. If no `enumerationMember` (or
combination of named enumeration members) is
available, the `enumMemberValue` representation may be used.

Geography and geometry values are represented as geometry types as
defined in [RFC7946](#rfc7946), with the following
modifications:

- Keys SHOULD be ordered with type first, then coordinates, then any other keys
- If the optional [CRS
object](http://geojson.org/geojson-spec.html#named-crs) is present, it
MUST be of type `name`, where the value of the
`name` member of the contained `properties` object
is an EPSG SRID legacy identifier, see [[GeoJSON-2008](#GeoJSON-2008)].

Geography and geometry types have the same representation in a JSON
payload. Whether the value represents a geography type or geometry type
is inferred from its usage or specified using the
[`type`](#ControlInformationtypeodatatype)
control information.

::: example
Example ##ex:
```json
{
"NullValue": null,
"TrueValue": true,
"FalseValue": false,
"BinaryValue": "T0RhdGE",
"IntegerValue": -128,
"DoubleValue": 3.1415926535897931,
"SingleValue": "INF",
"DecimalValue": 34.95,
"StringValue": "Say \"Hello\",\nthen go",
"DateValue": "2012-12-03",
"DateTimeOffsetValue": "2012-12-03T07:16:23Z",
"DurationValue": "P12DT23H59M59.999999999999S",
"TimeOfDayValue": "07:59:59.999",
"GuidValue": "01234567-89ab-cdef-0123-456789abcdef",
"Int64Value": 0,
"ColorEnumValue": "Yellow",
"GeographyPoint": {"type": "Point", "coordinates": [142.1,64.1]}
}
```
:::

## ##subsec Complex Value

A complex value is represented as a single JSON object containing one
name/value pair for each property that makes up the complex type. Each
property value is formatted as appropriate for the type of the property.

It MAY have name/value pairs for [instance annotations](#InstanceAnnotations) and control information.

::: example
Example ##ex:
```json
{
"@context": "http://host/service/$metadata#Customers/$entity",
...
"Address": {
"Street": "Obere Str. 57",
"City": "Berlin",
"Region": null,
"PostalCode": "D-12209"
}
}
```
:::

A complex value with no selected properties, or no defined properties
(such as an empty open complex type or complex type with no structural
properties) is represented as an empty JSON object.

## ##subsec Collection of Primitive Values

A collection of primitive values is represented as a JSON array; each
element in the array is the representation of a [primitive
value](#PrimitiveValue). A JSON literal `null` represents
a null value within the collection. An empty collection is represented
as an empty array.

::: example
Example ##ex: partial collection of strings with next link
```json
{
"@context": "http://host/service/$metadata#Customers/$entity",
...
"EmailAddresses": [
"[email protected]",
"[email protected]"
],
"EmailAddresses@nextLink": "..."
}
```

## ##subsec Collection of Complex Values

A collection of complex values is represented as a JSON array; each
element in the array is the representation of a [complex value](#ComplexValue). A JSON literal `null` represents a
null value within the collection. An empty collection is represented as an empty array.

::: example
Example ##ex: partial collection of complex values with next link
```json
{
"PhoneNumbers": [
{
"Number": "425-555-1212",
"Type": "Home"
},
{
"@type": "#Model.CellPhoneNumber",
"Number": "425-555-0178",
"Type": "Cell",
"Carrier": "Sprint"
}
],
"PhoneNumbers@nextLink": "..."
}
```

## ##subsec Untyped Value

OData 4.01 adds the built-in abstract types `Edm.Untyped` and
`Collection(Edm.Untyped)`that services can use to advertise
in metadata that there is a property of a particular name present, but
there is no type to describe the structure of the property's values.

The value of an `Edm.Untyped` property MAY be a primitive
value, a structural value, or a collection. If a collection, it may
contain any combination of primitive values, structural values, and
collections.

The value of a property of type `Collection(Edm.Untyped)`MUST
be a collection, and it MAY contain any combination of primitive values,
structural values, and collections.

Untyped values are the only place where a collection can directly
contain a collection, or a collection can contain a mix of primitive
values, structural values, and collections.

All children of an untyped property are assumed to be untyped unless
they are annotated with the
[`type`](#ControlInformationtypeodatatype)
control information, in which case they MUST conform to the type
described by the control information.
Loading

0 comments on commit 91421ae

Please sign in to comment.