Minecraft – the correct syntax for using a command block to place a wall sign

minecraft-commandsminecraft-java-edition

I am trying to use the /setblock command to place a wall sign and while I manage to find success in placing the sign, it doesn't include the text. I have looked all over and there seems to be various ways to write the command. This is the command that I got to work:

/setblock minecraft:wall_sign 4 replace
{Text1:{text:""},Text2:{text:"Room"},Text3:{text:"Two"},Text4:{text:""}}

Here is an image of the sign posted when the command is entered:
wall_sign placed with no text

I don't understand why it is placing the sign without the text. I have read the wiki and even seen other sources say that all I need in the code is the following:

/setblock minecraft:wall_sign 4 replace
{Text2:"Room",Text3:"Two"}

However, this always gives me an error, as you can see in this picture:
error messages

Any help would be appreciated.

Best Answer

The text portion should be specified in JSON format.

Example command:

/setblock <x> <y> <z> wall_sign 4 replace {Text2:"{\"text\":\"Room\"}",Text3:"{\"text\":\"Two\"}"}

I recommend visiting the wiki on signs, specifically the block entity section for more information.