Minecraft – Why is the command throwing a ‘data tag parsing failed’ error

minecraft-commandsminecraft-java-edition

I am trying to lock some boxes in a map of mine, and I used this command:

/blockdata 10 4 9 {Lock:Elyiana's Mage Key}

At first it worked, but then when I logged back on the next day it gave me this error message:

Data tag parsing failed: Expected '}' but ''' at: {Lock:Elyiana'<--[HERE]  

I don't know why it doesn't like the apostrophe in the key's name. I would change it, but it already worked and locked some other items. My version is 1.12, does anyone have an answer to my problem?

Best Answer

As of 1.12 you have to encase Strings containing special characters (including spaces and apostrophes) with quotes (" ").

/blockdata 10 4 9 {Lock:"Elyiana's Mage Key"}

This should do the trick.