Tilde in reserved characters

I have been using JSON:API in projects at my day job for some amount of time and really like to implement APIs by this standard. I think the flat structure of collections (of resource objects) and the simple URLs that result from it are a key strength.

However this flat structure now produces some headaches in one of my private projects. I have some types that are closely related to each other and thus I want to add the same prefix to those that make a group of related resources, effectively adding namespaces to member names:

For example:
“type”: “windows::file” or
“type”: “windows::user” or
“type”: “linux::file” or
“type”: “linux::user”

I hope you get the idea.

Of course the colons cannot be used to separate the parts within the member name. In fact according to the spec, the only characters that could be used to separate them are “_” or “-”. It makes perfect sense since those characters do not need to be percent-encoded.
However I feel putting an underscore as separator between my “namespace”/prefix and the rest does not convey the correct semantic meaning.

Another character that does not need to be percent-encoded in URLs is the tilde (“~”). But the tilde appears in the list of reserved characters in the JSON:API spec.

Since the tilde is not used within the spec for any special case (contrary to e.g. the period “.”) my question is: Why is the tilde not allowed in member names?

I hope some of you can shed some light on this. Thank you in advance!

Tilde (~) has some historic baggage in URLs. People may still associate it with mapping URLs to users.

RFC 1738 required percentage encoding for tilde in URL. That only got relaxed later in RFC 2396.

I don’t get why underscore (_) or dash (-) should be less optimal separator. Can you please elaborate?

Personally I would go with windowsFile, windowsUser, linuxFile, and linuxUser to be honest .

I suspected that tilde may come with some historical baggage and that may be the reason why its use is discouraged. Thank you for the explanation!

I guess I will settle with the dash as word separator. I suppose it boils down to personal preference and I would have liked to work out an JSON:API implementation that uses the tilde inside member names. But I can see why it may be better to simply use camelCase or another, baggage-less separator.

Thanks again!