Mojira Archive
MC-261742

I think that raw json text interpret should be executed on the lenient GSON.

related issue

 

I used MCP_Reborn to determine the cause but I do not publish raw source codes.

 

the interpret process is:

'{"nbt":"xxx","storage":"minecraft:test","interpret":true}'

if I have

minecraft: {test: {xxx: ["aaa","bbb","ccc"]}}

the nbt gets toString()

String nbt_xxx = "[\"aaa\",\"bbb\",\"ccc\"]";

GSON library interprets it

gson.setLenient(false);
gson.read("[\"aaa\",\"bbb\",\"ccc\"]"); 

then it is resolved to

'{"extra":[{"text":"bbb"},{"text":"ccc"}],"text":"aaa"}'

 

So If I have

{xxx: ["aaa","bbb","ccc"]} or {xxx: '["aaa","bbb","ccc"]'}

These nbt get toString() and become same String so the data type of nbt_list or nbt_string does not make any difference in this case.

 

but If I have strings which contains double quotations

yyy1: ['aa"a'] or yyy2: '["aa\"a"]'

toString()

String nbt_yyy1 = "['aa\"a']";
String nbt_yyy2 = "[\"aa\\\"a\"]";

then

gson.setLenient(false);
gson.read("['aa\"a']"); // throws com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON
// You can also get this error message by executing /tellraw @p ['a']
gson.read("[\"aa\\\"a\"]"); // correct

Not lenient GSON does not accept single quotations but nbt toString() single quotes the string which has double quotes, so I cannot use interpret when it contains double quotes.

I can use interpret by quoting the entire list but I cannot append elements dynamically.

 

Book and Quill have similar process.

{id:"minecraft:writable_book",tag:{pages:["aaaa","bbbbb",'cc"cc']}

If I "Sign and Close" it, It is resolved by similar process

gson.setLenient(true);
gson.read("[\"aaaa\",\"bbbbb\",'cc\"cc']");

In this case, lenient GSON is used, so it handle the string which has double quotes correctly.

pages:['{"text":"aaaa"}','{"text":"bbbbb"}','{"text":"cc\\"cc"}']

 

Book and Quill can handle double quotes, but raw json text interpret cannot, so in my opinion, this interpret specification is buggy.

Invalid

ArithAuth

2023-04-09, 05:25 AM

2023-04-09, 11:00 AM

2023-04-09, 09:51 AM

0

1

Unconfirmed

(Unassigned)

1.19.4

-