Closed varyandeveloper closed 3 years ago
Thanks for reporting bug, could you share a sample of the json file?
Let me share the link to the file.
https://drive.google.com/file/d/1dUx7IAXmxD7ifuO5_hyeQnoEmC6GY8d3/view?usp=sharing
I can confirm (reproduce) the bug with your sample file.
For example, the original "name": "__THECONN__",
becomes "name": ["__THECONN__"],
.
I'm looking into why.
I've reduced it to a minimal data that reproduce the bug.
Original Data:
{
"any-1": {
"key-and-value": "any-3"
},
"any-2": "key-and-value"
}
Decompressed Data:
{
"any-1": {
"key-and-value": "any-3"
},
"any-2": [
"key-and-value"
]
}
It seems to happen when a string value appears both as object key and object value. Will try to figure out why.
The cause is identified. Related to caching (The array of Object.keys() are converted into string (using array.join(',')
).
Will fix it soon
Awesome,
Thank you a lot for your fast response and effort to make it better.
I really appreciate, in fact, this package is the best for compressing JSON as it makes content smaller than other popular packages like compressed-json and jsonpack.
Applied a fix and it can pass the reduced test case. It is released as 2.0.0.
However, it seems still cannot pass the provided sample file. Continue debugging :muscle:
Thank you for your appreciation. Indeed, this package is inspired from the algorithms used in the two mentioned packages.
The reported bug(s) should have been fixed in compress-json@2.0.1. @varyandeveloper, might you confirm that with your data set? Thanks.
Yes, I can confirm that this issue was fixed.
Thank you again.
Great work, but I found another issue that prevents me to use this package as a JSON pack/unpack tool.
` const data = require('./my-data.json'); const { compress, decompress } = require('compress-json'); const assert = require('assert');
assert.deepStrictEqual(decompress(compress(data)), data); `