PrismarineJS / node-mojangson

A mojangson parser written in node.js
17 stars 9 forks source link

Fix problems with stringifying unquoted strings, and fix parsing strings such as "1b" #35

Closed ChipmunkMC closed 1 year ago

ChipmunkMC commented 2 years ago
u9g commented 2 years ago

can you show something this fixes?

ChipmunkMC commented 2 years ago

@u9g This fixes:

> const snbt = require('mojangson')
undefined
> const nbt = require('prismarine-nbt')
undefined
> snbt.parse('"1b"')
{ value: 1, type: 'byte' }
> snbt.stringify(nbt.comp({ string: nbt.string("'this string will be normalized twice") }))
`{string:"\\"'this string will be normalized twice\\""}`
> snbt.stringify(nbt.string("a character that isnt allowed in unquoted strings \u6969"))
'a character that isnt allowed in unquoted strings 楩'
rom1504 commented 2 years ago

can you add that to the tests ?

ChipmunkMC commented 2 years ago

can you add that to the tests ?

Sorry for the delay, I added some strings to the stringify test data, to test quoting.

rom1504 commented 1 year ago

conflicts

rom1504 commented 1 year ago

please re-open if you want to finish it