-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Conversion Spec #55
Comments
Discussions from Discord
// SNBT
{
Hello: 0b,
Nice: true,
Hi: {
Heya: [B;0b,1b,2b,3b,4b,5b]
}
}
// ... to JSON
{
"Hello": 0,
"Nice": true,
"Hi": {
"Heya": [0,1,2,3,4,5]
}
}
// NBT (represented here as NBT)
{
Hello: 0.0d,
Nice: 0b,
Hi: {
Heya: [0.0d,1.0d,2.0d,3.0d,4.0d,5.0d]
}
}
|
Further discussions from Discord
|
I didn't realize the Java Edition has an in-built mechanism that converts JSON <=> NBT, I thought the concept behind that was just a mechanic of users working with NBT data outside of the game itself, like with third-party projects like yours truly.
JSON and NBT - Minecraft Wiki
If this does have a specific intended behavior for converting to and from NBT and JSON primitives, then this is a spec that NBTify itself should also follow. As of yet, I decided to essentially only make safe conversions for working with JSON itself, without any implied value range inferences, say for example whether a value is small enough to fit inside of a
TAG_Byte
, that shouldn't dictate that it's type is indeed that size, because when the game loads that file, it might be expecting a different number type. This concept was worrisome to me, so I went with what seemed like the least opinionated route, where it would only convert types when they safely could assumed to be such. For example, going from JS booleans toTAG_Byte
is okay, because this is what NBT itself does too. However, converting aTAG_List
ofTAG_Byte
values to aTAG_Byte_Array
doesn't seem as straightforward, so I don't do that.If this behavior is expected though, then it is something that NBTify should allow for too. Personally, I think for general JSON out in the world, the current NBTify implementation for conversion works well for that, because it doesn't assume anything to be safe coming in. However, in an expected scenario of data coming in from the game, and you know where it's reading into (like player data for example), then if the game is okay with key-value pairs being of different types, then conversion doesn't seem to be much of an issue.
The text was updated successfully, but these errors were encountered: