Closed Offroaders123 closed 1 year ago
I'm considering not supporting the NBT primitive to JSON string, part of the feature. I'm not sure it can be secure enough to be used securely every time, since the type suffix at the end of the string, for the number, can't really be fully protected against just having a letter at the end of the number string, in a regular string. I think it's not too nice of a setup to work with. I'm still gonna try it out to see, but I may only do the JSON primitive-supporting NBT part. That means that it will serialize the NBT down to JSON, and it will likely coalesce the custom NBT primitives down to the ones that JSON can handle.
If your set of NBT data only uses NBT primitives that fall within the JSON spec, then I think it would still be very neat to have an API to read and write from JSON with those. My only concern about the other feature is running into false-positives, and that the output JSON would kind of look odd too.
Now that the library has been fully using bare JavaScript primitives to represent the NBT data structures, you essentially get first-class JSON support out of the box, and it's not something that NBTify has to directly manage when going to and from JSON, if you're using JSON-compliant NBT values, so essentially the non-TypedArray ones, no BigInt values, and only the Double number tag type. And, the NBT structure-related requirements, like List tag types having single item types, and non-recursive List item and Compound tag references.
So essentially, if you're data structures are compliant with JSON, they are already compliant with being saved to NBT and SNBT, the only hindrance being that array items must all be of the same type, and that you have to expect Byte tag values in place of raw Boolean values after reading the data from a raw NBT file.
Similar to #4, but using just plain JSON. I'd like to be able to export standard JavaScript JSON to NBT, for things like a JavaScript game's save data. And kind of the other way around, it would be nice to export regular NBT, with all of it's custom non-JSON tag types, as JSON too. Ideally I think one would want to use SNBT to edit full NBT, better than my custom JSON edit, but I think the JSON version may also be a bit better supported by less complicated text editors, ones that might not detect
.snbt
files off the bat. It will likely resolve the nonNumber
based number values into strings with the type suffix following the value. Essentially, a string wrapper for the value, and it looks like how SNBT would.