-
Notifications
You must be signed in to change notification settings - Fork 32
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
It is not clear enough what "JSON Serialization" is #605
Comments
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. |
Discussed on [today's call](https://json-ld.org/minutes/2024-07-10/#55).#605 -> Issue 605 It is not clear enough what "JSON Serialization" is (by anatoly-scherbakov) [spec:editorial] [ErratumRaised] ✪
Gregg Kellogg: Perhaps extract the json serialization for responding to a content type request. ✪
Anatoly Scherbakov: We could specify a "serialize()" function to do this, if it takes a content type. ✪
... The API can describe when to serialize.
... I wanted to be sure that we agree that an expand function should return a datastructure, and not a serialization.
Pierre-Antoine Champin: I misunderstood what you said before, and agree that we should fix the API definitions. ✪
Niklas Lindström: Also agree to fix, but "do less". :) ✪
... I understand anatoly-scherbakov's concerns about how to define this, but also worry about what this could disrupt.
|
I've prepared a PR for this simple change: #608 |
Context
#579 (for JSON-LD 1.1 API) or json-ld/yaml-ld#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? 🤔
The text was updated successfully, but these errors were encountered: