mojira.dev
MC-270949

Single quotes cannot be used in lore component of text components

The lore of items has always used single and double quotation marks.
Use the following command to obtain a stick with lore:

/give @s stick[minecraft:lore=[' "text" ']] 1
[media]

But in "hoverEvent" of text components, in "show_item", the lore component can only use two layers of double quotes, and cannot use single quotes to wrap double quotes, otherwise it will get a malformed JSON error.

Use the following command to tellraw text carrying hoverEvent to all players, which can display a grass block with lore:

/tellraw @a [{"text":"[ITEM]","hoverEvent":{"action":"show_item","contents":{"id":"minecraft:grass_block","count":32,"components":{"minecraft:lore":[" \"text\" "]}}}}]
[media]

It works because we used two layers of double quotes.

But the following command will result in an error:

/tellraw @a [{"text":"[ITEM]","hoverEvent":{"action":"show_item","contents":{"id":"minecraft:grass_block","count":32,"components":{"minecraft:lore":[' "text" ']}}}}]
[media]

Attachments

Comments 1

WAI; using single quotes in JSON is malformed. The give command is allowed to use single quotes because it is not JSON.

Mini_Ye

(Unassigned)

Unconfirmed

(Unassigned)

1.20.5 Release Candidate 2

Retrieved