Messages 2.5.2 - Example for accessing language-tagged claims

Issue #810 wontfix
Justin Richer
created an issue

The use of the hashtag (#) to mark language/script in human-readable claims doesn't play well with object-based field access in most programming languages. While this is still a valid JSON member name, and all languages have some means of accessing the values, there is an inherent limitation in what many programmers will expect to be available for their parsed objects.

So for the JSON:

{ "client_name": "Test Client", "client_name#en-us": "Test Client" }

You get a JSON object with two members, one of which can be access as:

object.client_name => "Test Client"

or its equivalent. But the other must be accessed as:

object["client_name#en-us"] => "Test Client"

or its equivalent.

To combat this, we could change how we do language tags (not really a good idea, because the "-" character is also invalid in many languages for a member name), or we could simply add a quick example in a common programming language, like JavaScript, to call out this limitation.

Comments (3)

  1. Log in to comment