The bug
When using the new "score" JSON text component, you cannot reference a name that contains non-alphanumeric characters. Hyphens, underscores, and periods are accepted.
Steps to reproduce
Create a new scoreboard objective with a fake player containing a non-alphanumeric character:
/scoreboard objectives add foo dummy /scoreboard players set "#example" foo 1
Try to print the fake player's score value in chat:
/tellraw @a {"rawtext":[{"score":{"name":"#example","objective":"foo"}}]}
→ ❌ Syntax error: Unexpected "#": at ">>#<<example"
Additional findings
Notice how to set a scoreholder with a non-alphanumeric character, quotation marks are required around the scoreholder's name:
Therefore, logically, to retrieve this score value, quotation marks will need to surround the scoreholder's name in the JSON text.
Our current text is:
This means that when the JSON test looks up the score, it is looking up:
#example
for the scoreholderfoo
for the objectiveNotice something? No quotation marks!
The next logical step to find a solution would be to add an inner set of quotation marks around the scoreholder's name:
Notice the use of backslashes to insure the inner quotation marks are not interpreted as part of the JSON structure.
When this JSON text is printed, we no longer have an error message.
❌ However, there is instead no output. No output is printed, even though a score is set.
It can be confirmed that putting inner quotation marks is correct because the same can be done for any other username, e.g. your own:
✔ The score output is printed correctly.
Conclusion
It appears that the JSON text resolution system is currently not prepared to handle usernames with non-alphanumeric characters, even when queried in the correct manner. However, such usernames are valid scoreholders within other aspects of the scoreboard system. Therefore, it is most likely unintended that the JSON text does not support these usernames, and this is a bug.
In addition, usernames like these are chosen frequently to be scoreholders because they contain characters that will never appear in a real Minecraft username. If a user with the same name as a fake scoreholder joins the game, this could have unintended effects if a command system detects them as a player. It would be appreciated by many if this could be fixed, which would increase the efficiency of development by allowing fake scoreholders to be printed directly.