mojira.dev
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.

Comments 4

This site is for bug reports only, for feature requests, go to the feedback site.

Interpret is supposed to only accept strings with json text, and all interpret does, is un-string it. NBTis not a format that matches json, only looks similar.

I see.
It just so happens that they accept NBT in some cases; the support is originally limited to strings.
Thank you.

Thank you for your report!
However, this issue is Invalid.

You have posted a feature request or a suggestion. This site is for bug reports only.
For suggestions, please visit Minecraft Suggestions on Reddit or visit the Feedback website.

Also, for the future: Please follow the bug tracker guidelines, linked below. In particular, state clearly what your problem is (in this case, including an example command), what you would expect to happen, and what actually happens.
You can still add a code analysis to the bug report, but it should not be the main focus.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

Sorry for not following the guidelines.
MC-260942
My issue is exactly the same as this Issue.
I made a detailed analysis of this issue, as I thought this was a bug and not a specification.

The comment I received made it clear that in json interpret, it is not intended that non-string formatted NBTs are used in the first place, so it is no wonder that the strange behavior occurs.

Thank you for your response and resolving the issue.

ArithAuth

(Unassigned)

Unconfirmed

(Unassigned)

1.19.4

Retrieved