Skip to content

spec is agnostic about keys starting with @ in object used as attribue values #1631

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

Closed
wants to merge 1 commit into from

Conversation

jelhan
Copy link
Contributor

@jelhan jelhan commented Jun 13, 2022

Clarify that JSON:API specification does not put any constraints on attribute values. Especially it leaves it up to implementation how to treat keys starting with @ in objects used as attribute values.

Assuming the following JSON:API document, an implementation would be allowed to ignore or process the @comment key.

{
  "data": {
    "type": "person",
    "id": "42",
    "attributes": {
      "address": {
        "@comment": "Would be nice to live here!",
        "street": ["123 Main St.", "Suite 24"],
        "city": "Someplace Warm",
        "state": "CA",
        "postcode": "90120"
      }
    }
  }
}

I see this as a clarification not as a breaking change. However without that note it was not fully clear how to handle that case. This issue was raised in #1584.

I hope that this clarification together with dropping any other constraints on attribute values (#1630) is enough to avoid further confusion.

Closes #1584

@jelhan jelhan added this to the v1.1 milestone Jun 13, 2022
@jelhan jelhan requested a review from dgeb June 13, 2022 17:15
@dgeb
Copy link
Member

dgeb commented Jun 20, 2022

I don't think this extra clarification is necessary given this statement in the same section:

@-Members MAY appear anywhere in a JSON:API document.

@dgeb
Copy link
Member

dgeb commented Jun 20, 2022

I just closed #1367 with the comment:

Upon reading and re-reading these issues and the current v1.1 section on @ members, it now is clear to me that @ members are fully in the domain of implementation semantics rather than specification semantics. As such, their usage can be governed by profiles, but not the base spec or extensions.

I think that explicitly focusing on the contents of attribute values doesn't really help clarify this central point. But I am open to broader clarifications.

@jelhan
Copy link
Contributor Author

jelhan commented Jun 21, 2022

It's see your point. Treating @-Members as implementation specific resolves my confusion. I think it also addresses the question raised by @freddrake in #1584.

However I'm not eure if current specification expresses that intent well.

JSON:API processors MUST completely ignore @-Members

This statement does not express that it's up to the implementation how to handle @-Members. Instead it seems to forbid depending on them at all.

It includes an example to clarify what ignore means:

i.e. not treat them as JSON:API data

That example confuses me even more to be honest. The term "JSON:API data" does not seem to be defined. Is the data represented as a JSON:API resource part of that JSON:API data?

Also what is meant by a "JSON:API processor" does not seem to be defined well. What part of processing the request/response and the data encoded in it is done by "JSON:API processor"? Which part is done by domain-specific processors?

This leads to a couple of specific questions:

  1. Is it okay to validate for presence or absence of a key starting with @ in an object used as attribute value?
  2. Should a server treat a key starting with @ of an object used as attribute value as part of the data encoded by the JSON:API resource object? Should it remove that key before persisting the data?

I think you are right. It's not that much about adding a special note for objects used as attribute values. Maybe it's more about clarifying that paragraph.

@freddrake
Copy link
Contributor

In particular, "JSON:API processor" is not defined in the specification.

I suspect the intent is that the parts of an application that deal with JSON:API structures specifically should ignore the @-members, but other aspects of the application (JSON-LD processors?) can handle them as they see fit.

This statement that JSON:API processors must completely ignore @-members needs to be rewritten to avoid the undefined term, either by defining the term clearly somewhere, or by stating @-members are allowed in JSON:API-defined structures, but have no impact on JSON:API-defined interpretation of the structures.

@dgeb
Copy link
Member

dgeb commented Jun 21, 2022

@jelhan @freddrake I agree that there is a lot to be improved with this section about @ members.

The wording around "JSON:API processors" is unclear. The intention is basically "servers and clients interpreting this specification". Now of course, these same servers and clients should interpret these @ members in another context, such as through JSON-LD.

This leads to a couple of specific questions:
Is it okay to validate for presence or absence of a key starting with @ in an object used as attribute value?
Should a server treat a key starting with @ of an object used as attribute value as part of the data encoded by the JSON:API resource object? Should it remove that key before persisting the data?

These questions are not the domain of this specification, but rather the specific implementation (which may provide instructions via a profile). JSON:API can't answer these questions any more than it can provide instructions about interpreting meta values.

I will attempt to clarify this whole section in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@-members question: treatment in objects nested under attributes?
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy