"Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate]
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"}]}"
Best Answer
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. \\\"
Pictures about ""Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate]"
!["Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate] - From above of crop anonymous male hacker typing on netbook with data on screen while sitting at desk "Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate] - From above of crop anonymous male hacker typing on netbook with data on screen while sitting at desk](/assets/images/quotdata_tag_parsing_failedquot_when_trying_to_setblock_a_command_block_with_a_command_in_it_duplicate_1.jpeg)
!["Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate] - Black Screen With Code "Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate] - Black Screen With Code](/assets/images/quotdata_tag_parsing_failedquot_when_trying_to_setblock_a_command_block_with_a_command_in_it_duplicate_2.jpeg)
!["Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate] - Javascript Code "Data tag parsing failed" when trying to setblock a command block with a command in it [duplicate] - Javascript Code](/assets/images/quotdata_tag_parsing_failedquot_when_trying_to_setblock_a_command_block_with_a_command_in_it_duplicate_3.jpeg)
How do you Setblock a command block with a command in it bedrock?
How to Enter the CommandHow do you use command blocks with Setblock?
Command blocks can only be obtained by running a command.How do you get command blocks with commands?
It can either be obtained by using the pick block control, or by using various commands, such as /give @s minecraft:command_block , or /setblock ~ ~ ~ command_block . Just like other blocks that can store NBT data, using pick block + CTRL copies the command and options inside the command block.Learning Minecraft Command Block Programming, Part 9 - JSON, tellraw, and clickable signs
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Anete Lusina, Sora Shimazaki, Antonio Batinić, Markus Spiske

