NBT-API

NBT-API

98.9k Downloads

NBTCompound#asNBTString does not return always return "A json valid nbt string"

drunderscore opened this issue ยท 1 comments

commented

The documentation here claims that NBTCompound#asNBTString will return a valid JSON string, when in reality that is not always the case.

Mojang JSON is a special subset of JSON. In normal JSON, the only numerical data type is number, whereas Mojang JSON allows for suffixes on the value to specify the specific data type.

Two simple examples:
ItemStack of a single Diamond Shovel: {id:"minecraft:diamond_shovel",tag:{Damage:0},Count:1b}
The b suffix on the value of the Count property specifies this is a byte datatype. Not valid JSON.

ItemStack of a single Diamond Sword with Sharpness 3: {id:"minecraft:diamond_sword",tag:{Damage:0,Enchantments:[{id:"minecraft:sharpness",lvl:3s}]},Count:1b}
The s suffix on the value of the lvl property specifies this is a short datatype. Not valid JSON.

It would be more correct to either specify this is not JSON, rather Mojang json, or correct the method in question to return valid JSON, or remove the documentation of any JSON support entirely.

commented

Thanks, yea that's correct. I will correct the documentation later/you can open a pr if you want ๐Ÿ‘