Open anatoly-scherbakov opened 6 days ago
We definitely need to clean this up. Probably, clarify that the API methods return the JsonLdRecord (or sequence of JsonLdRecord) which is the WebIDL description of the internal representation, although internal representation includes map, array, number, or JSON Literal.
Probably something in the API section that generally says that the default serialization of the resulting internal representation is JSON and that processors MUST return this value when application/json or a subtype is expected.
Context
https://github.com/w3c/json-ld-api/issues/579 (for JSON-LD 1.1 API) or https://github.com/json-ld/yaml-ld/issues/143 (for YAML-LD, which derives from JSON-LD) seem to stem from a common issue: a reader of the API specification might be unclear about what is meant under "JSON Serialization" in the spec.
§ 1.5 Example Conventions says:
A programmer will likely expect that JSON Serialization is a string. For instance, Working With JSON Data in Python → Serializing JSON says:
The explanation in the API will not convince the reader otherwise. § 9.1 The JsonLdProcessor Interface →
expand()
instructs the implementation, at item 9), toThus,
expand()
output type must be aString
. Right?No. Because the same § 9.1 The JsonLdProcessor Interface section, in its IDL block, specifies:
In fact, the
expand()
return value is a sequence ofJsonLdRecord
objects, which probably are represented asmap
(or as anobject
, or as adict
) in the programming language powering an implementation.Alternatives
Also
I think we need to also very explicitly explain the difference among
JsonLdRecord
, on the one hand,with an example.
Decision
(TODO: subject to discussion)
In the placeholder above, I will summarize what we've come up with, for future reference.
What do you think? :thinking: