This question already has an answer here:

I'm trying to fix this but it doesn't work. Inside the command block. I typed in

/setblock 125 64 617 minecraft:command_block 0 replace {Command:"testfor @a {Inventory:[{id:"minecraft:bedrock"}]}"}

and it said:

[09:58:00] Data tag parsing failed: Unexpected token 'm' at: minecraft:bedrock"}]}"

enter image description here

marked as duplicate by greg-449, Virusbomb, bearb001, Gigazelle, arghtype Jul 9 at 22:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    @angussidney not a duplicate. The linked question does not have nested strings, which cause the issue here. – MrLemon Jun 13 '16 at 8:19

The quotation mark at the end of id:" makes Minecraft think your Command tag ends right there. It is followed by m, which minecraft is confused about, since it expects either a comma, followed by a new tag, or a closing bracket.

To prevent this, you have to escape the "inner" quotation marks using a backslash (\) character, like so:

/setblock 125 64 617 minecraft:command_block 0 replace {Command:"testfor @a {Inventory:[{id:\"minecraft:bedrock\"}]}"}

\" is a literal quotation mark character, which the game doesn't confuse for the end of the string.

Note: Should you ever encounter even deeper nested strings (this can happen when you use raw JSON text with clickEvents or such), you have to escape the escape characters as well, e.g. \\\"

Not the answer you're looking for? Browse other questions tagged or ask your own question.