json-as 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +400 -0
- package/README.md +137 -32
- package/assembly/deserialize/index/arbitrary.ts +1 -1
- package/assembly/deserialize/index/array.ts +6 -1
- package/assembly/deserialize/index/float.ts +1 -1
- package/assembly/deserialize/index/integer.ts +1 -1
- package/assembly/deserialize/index/typedarray.ts +14 -0
- package/assembly/deserialize/index/unsigned.ts +1 -1
- package/assembly/deserialize/simd/string.ts +20 -16
- package/assembly/deserialize/simple/arbitrary.ts +1 -1
- package/assembly/deserialize/simple/array/generic.ts +42 -0
- package/assembly/deserialize/simple/array.ts +8 -1
- package/assembly/deserialize/{float.ts → simple/float.ts} +22 -2
- package/assembly/deserialize/{integer.ts → simple/integer.ts} +3 -2
- package/assembly/deserialize/simple/map.ts +60 -12
- package/assembly/deserialize/simple/object.ts +1 -1
- package/assembly/deserialize/simple/set.ts +119 -134
- package/assembly/deserialize/simple/staticarray.ts +12 -1
- package/assembly/deserialize/simple/string.ts +93 -2
- package/assembly/deserialize/simple/struct.ts +7 -157
- package/assembly/deserialize/simple/typedarray.ts +1 -1
- package/assembly/deserialize/{unsigned.ts → simple/unsigned.ts} +3 -2
- package/assembly/deserialize/swar/array/array.ts +42 -7
- package/assembly/deserialize/swar/array/bool.ts +5 -2
- package/assembly/deserialize/swar/array/float.ts +7 -3
- package/assembly/deserialize/swar/array/generic.ts +40 -0
- package/assembly/deserialize/swar/array/integer.ts +7 -4
- package/assembly/deserialize/swar/array/object.ts +20 -4
- package/assembly/deserialize/swar/array/shared.ts +18 -4
- package/assembly/deserialize/swar/array/string.ts +5 -2
- package/assembly/deserialize/swar/array/struct.ts +20 -4
- package/assembly/deserialize/swar/array.ts +56 -2
- package/assembly/deserialize/swar/string.ts +245 -370
- package/assembly/index.ts +207 -194
- package/assembly/serialize/index/arbitrary.ts +8 -3
- package/assembly/serialize/index/float.ts +1 -1
- package/assembly/serialize/index/object.ts +1 -5
- package/assembly/serialize/index/typedarray.ts +65 -0
- package/assembly/serialize/simd/string.ts +7 -16
- package/assembly/serialize/simple/arbitrary.ts +9 -3
- package/assembly/serialize/simple/array.ts +17 -6
- package/assembly/serialize/simple/float.ts +18 -4
- package/assembly/serialize/simple/map.ts +10 -27
- package/assembly/serialize/simple/object.ts +1 -5
- package/assembly/serialize/simple/set.ts +3 -4
- package/assembly/serialize/simple/staticarray.ts +4 -3
- package/assembly/serialize/simple/string.ts +3 -11
- package/assembly/serialize/simple/typedarray.ts +9 -7
- package/assembly/serialize/swar/string.ts +3 -12
- package/assembly/tsconfig.json +3 -2
- package/assembly/util/dragonbox-cache.ts +1322 -0
- package/assembly/util/dragonbox.ts +596 -0
- package/assembly/util/swar.ts +49 -0
- package/lib/as-bs.ts +92 -70
- package/package.json +35 -10
- package/transform/lib/index.d.ts +1 -0
- package/transform/lib/index.d.ts.map +1 -1
- package/transform/lib/index.js +559 -221
- package/transform/lib/index.js.map +1 -1
- package/transform/lib/linkers/custom.d.ts.map +1 -1
- package/transform/lib/linkers/custom.js +7 -3
- package/transform/lib/linkers/custom.js.map +1 -1
- package/transform/lib/types.d.ts +2 -0
- package/transform/lib/types.d.ts.map +1 -1
- package/transform/lib/types.js +13 -0
- package/transform/lib/types.js.map +1 -1
- package/.as-test/coverage/naive/coverage.arbitrary.spec.ts.log.json +0 -5628
- package/.as-test/coverage/naive/coverage.array.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.bool.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.box.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.custom.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.date.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.enum.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.float.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.generics.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.hierarchy.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.integer.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.map.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.namespace.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.null.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.raw.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.resolving.spec.ts.log.json +0 -5628
- package/.as-test/coverage/naive/coverage.set.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.staticarray.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.string.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.struct.spec.ts.log.json +0 -5187
- package/.as-test/coverage/naive/coverage.types.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.arbitrary.spec.ts.log.json +0 -5628
- package/.as-test/coverage/simd/coverage.array.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.bool.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.box.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.custom.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.date.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.enum.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.float.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.generics.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.hierarchy.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.integer.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.map.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.namespace.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.null.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.raw.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.resolving.spec.ts.log.json +0 -5628
- package/.as-test/coverage/simd/coverage.set.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.staticarray.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.string.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.struct.spec.ts.log.json +0 -5187
- package/.as-test/coverage/simd/coverage.types.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.arbitrary.spec.ts.log.json +0 -5628
- package/.as-test/coverage/swar/coverage.array.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.bool.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.box.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.custom.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.date.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.enum.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.float.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.generics.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.hierarchy.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.integer.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.map.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.namespace.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.null.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.raw.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.resolving.spec.ts.log.json +0 -5628
- package/.as-test/coverage/swar/coverage.set.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.staticarray.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.string.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.struct.spec.ts.log.json +0 -5187
- package/.as-test/coverage/swar/coverage.types.spec.ts.log.json +0 -5187
- package/.as-test/logs/naive/run.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/naive/run.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/naive/run.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/naive/run.box.spec.ts.log.json +0 -353
- package/.as-test/logs/naive/run.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/run.date.spec.ts.log.json +0 -397
- package/.as-test/logs/naive/run.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/naive/run.float.spec.ts.log.json +0 -453
- package/.as-test/logs/naive/run.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/naive/run.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/naive/run.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/naive/run.map.spec.ts.log.json +0 -247
- package/.as-test/logs/naive/run.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/naive/run.null.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/run.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/run.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/run.set.spec.ts.log.json +0 -733
- package/.as-test/logs/naive/run.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/naive/run.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/naive/run.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/naive/run.types.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/naive/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/naive/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/naive/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/naive/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/naive/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/naive/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/naive/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/naive/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/naive/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/naive/test.log.json +0 -2289
- package/.as-test/logs/naive/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/naive/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/naive/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/naive/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/naive/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/naive/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/naive/test.string.spec.ts.log.json +0 -2345
- package/.as-test/logs/naive/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/naive/test.types.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/run.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/simd/run.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/simd/run.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/simd/run.box.spec.ts.log.json +0 -353
- package/.as-test/logs/simd/run.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/run.date.spec.ts.log.json +0 -397
- package/.as-test/logs/simd/run.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/simd/run.float.spec.ts.log.json +0 -453
- package/.as-test/logs/simd/run.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/simd/run.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/simd/run.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/simd/run.map.spec.ts.log.json +0 -247
- package/.as-test/logs/simd/run.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/simd/run.null.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/run.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/run.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/run.set.spec.ts.log.json +0 -733
- package/.as-test/logs/simd/run.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/simd/run.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/simd/run.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/simd/run.types.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/simd/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/simd/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/simd/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/simd/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/simd/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/simd/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/simd/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/simd/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/simd/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/simd/test.log.json +0 -11371
- package/.as-test/logs/simd/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/simd/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/simd/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/simd/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/simd/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/simd/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/simd/test.string.spec.ts.log.json +0 -2345
- package/.as-test/logs/simd/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/simd/test.types.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/run.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/swar/run.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/swar/run.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/swar/run.box.spec.ts.log.json +0 -353
- package/.as-test/logs/swar/run.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/run.date.spec.ts.log.json +0 -397
- package/.as-test/logs/swar/run.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/swar/run.float.spec.ts.log.json +0 -453
- package/.as-test/logs/swar/run.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/swar/run.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/swar/run.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/swar/run.map.spec.ts.log.json +0 -247
- package/.as-test/logs/swar/run.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/swar/run.null.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/run.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/run.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/run.set.spec.ts.log.json +0 -733
- package/.as-test/logs/swar/run.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/swar/run.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/swar/run.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/swar/run.types.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/swar/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/swar/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/swar/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/swar/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/swar/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/swar/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/swar/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/swar/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/swar/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/swar/test.log.json +0 -11371
- package/.as-test/logs/swar/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/swar/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/swar/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/swar/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/swar/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/swar/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/swar/test.string.spec.ts.log.json +0 -2345
- package/.as-test/logs/swar/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/swar/test.types.spec.ts.log.json +0 -273
- package/.as-test/logs/test.arbitrary.spec.ts.log.json +0 -943
- package/.as-test/logs/test.array.spec.ts.log.json +0 -1053
- package/.as-test/logs/test.bool.spec.ts.log.json +0 -257
- package/.as-test/logs/test.box.spec.ts.log.json +0 -353
- package/.as-test/logs/test.custom.spec.ts.log.json +0 -309
- package/.as-test/logs/test.date.spec.ts.log.json +0 -397
- package/.as-test/logs/test.enum.spec.ts.log.json +0 -343
- package/.as-test/logs/test.float.spec.ts.log.json +0 -453
- package/.as-test/logs/test.generics.spec.ts.log.json +0 -393
- package/.as-test/logs/test.hierarchy.spec.ts.log.json +0 -325
- package/.as-test/logs/test.integer.spec.ts.log.json +0 -373
- package/.as-test/logs/test.log.json +0 -11371
- package/.as-test/logs/test.map.spec.ts.log.json +0 -247
- package/.as-test/logs/test.namespace.spec.ts.log.json +0 -361
- package/.as-test/logs/test.null.spec.ts.log.json +0 -273
- package/.as-test/logs/test.raw.spec.ts.log.json +0 -309
- package/.as-test/logs/test.resolving.spec.ts.log.json +0 -273
- package/.as-test/logs/test.set.spec.ts.log.json +0 -733
- package/.as-test/logs/test.staticarray.spec.ts.log.json +0 -931
- package/.as-test/logs/test.string.spec.ts.log.json +0 -2289
- package/.as-test/logs/test.struct.spec.ts.log.json +0 -523
- package/.as-test/logs/test.types.spec.ts.log.json +0 -273
- package/.as-test/runners/default.bindings.js +0 -68
- package/.as-test/runners/default.wasi.js +0 -38
- package/ARCHITECTURE.md +0 -323
- package/CONTRIBUTING.md +0 -244
- package/TODO +0 -1
- package/as-test.config.json +0 -40
- package/assembly/test.ts +0 -24
- package/eslint.config.js +0 -68
- package/lib/tsconfig.json +0 -8
- package/test.ts +0 -99
- package/tools/assemblyscript-eslint-local.js +0 -6
- package/tools/assemblyscript-eslint.js +0 -53
- package/tools/assemblyscript-prettier-plugin.js +0 -33
- package/tools/replacer.js +0 -63
- package/transform/tsconfig.json +0 -35
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 2026-04-13 - 1.3.2
|
|
6
|
+
|
|
7
|
+
- fix: remove the fast double parser dependency and return float deserialization to the local legacy parser path
|
|
8
|
+
- fix: restrict string field destination reuse/renewal to heap-backed strings only and avoid writing into static literal storage
|
|
9
|
+
- perf: reduce branching in string field write paths while preserving heap-backed reuse (`simple`, `swar`, `simd`, and shared `bs.toField`)
|
|
10
|
+
- tests: add string-field regression coverage for literal defaults and heap-backed output pointers
|
|
11
|
+
- tooling: fix d8 bench runner lint issues (`print` global and unused buffer id vars)
|
|
12
|
+
- tooling: align `bench` script to use `charts:build`
|
|
13
|
+
- docs: streamline README benchmark/docs sections and update benchmark chart command references
|
|
14
|
+
|
|
15
|
+
## 2026-03-19 - 1.3.0
|
|
16
|
+
|
|
17
|
+
- chore: exclude generated `.as-test` build artifacts from ESLint, tighten generic deserializer offset math, and remove the obsolete `run-tests.sh` helper
|
|
18
|
+
- fix: add built-in typed array and `ArrayBuffer` serialization and deserialization support, including transform-generated field handling inside `@json` classes
|
|
19
|
+
- fix: finish subtype-aware `StaticArray` deserialization for nested arrays, maps, JSON value types, transform-backed structs, and related regressions
|
|
20
|
+
- fix: tighten default-path runtime correctness for signed `JSON.Value`, `@omitif("...")`, escaped nested strings, raw-array string handling, and `JSON.Obj.from(...)`
|
|
21
|
+
- perf: add a SIMD string-field deserializer for fast-path object deserialization and align transform codegen with mode-specific field helpers
|
|
22
|
+
- perf: add direct SWAR and SIMD integer-array deserializers with reusable-storage fast paths and dedicated throughput benches
|
|
23
|
+
- refactor: add `assembly/serialize/index/*` and `assembly/deserialize/index/*` dispatchers and route the public API through them
|
|
24
|
+
- perf: speed up float deserialization with handwritten parser paths, bitwise power-of-ten handling, and batched fractional parsing
|
|
25
|
+
- fix: avoid pulling SIMD code into non-SIMD bench builds and make benchmark temp-file cleanup tolerant of missing `asc --converge` outputs
|
|
26
|
+
- compat: add compatability between json-as and try-as by ignoring methods prefixed by __try
|
|
27
|
+
- feat: gate generated fast struct deserialization behind `JSON_USE_FAST_PATH=1`
|
|
28
|
+
- refactor: make generated struct `__DESERIALIZE` methods return the advanced source pointer
|
|
29
|
+
- perf: tune SWAR and SIMD string deserialization to return plain strings directly and only allocate scratch space after the first escape
|
|
30
|
+
- perf: streamline split SWAR string field deserialization and string-buffer reuse on the fast path
|
|
31
|
+
- perf: simplify generated fast integer field parsing to reuse `srcStart` and offset-based stores
|
|
32
|
+
- perf: parse generated numeric fields in a single pass with typed integer, unsigned, and float field helpers
|
|
33
|
+
- perf: hand-tune `small.bench.ts` and refresh benchmark runner turbofan flag configuration
|
|
34
|
+
- bench: add a string deserialization head-to-head benchmark and simplify throughput/chart comparisons back to the final JS/NAIVE/SWAR/SIMD view
|
|
35
|
+
- fix: keep the fast generated path opt-in by default and restore the `large` benchmark slow-path behavior
|
|
36
|
+
- refactor: split numeric deserializers into dedicated `assembly/deserialize/{integer,unsigned,float}` modules
|
|
37
|
+
- tooling: expand benchmark chart metadata parsing for custom string benchmark series
|
|
38
|
+
- tests: add escaped-quote SWAR deserialization regressions around block boundaries
|
|
39
|
+
|
|
40
|
+
## 2026-02-18 - 1.2.6
|
|
41
|
+
|
|
42
|
+
- fix: support arbitrary nested arrays and objects [#176](https://github.com/JairusSW/json-as/pull/176)
|
|
43
|
+
- chore: add contributor from [#176](https://github.com/JairusSW/json-as/pull/176)
|
|
44
|
+
- tests: significantly expand coverage across every file in `assembly/__tests__`
|
|
45
|
+
- tests: add additional primitive, array, nested payload, and escaped string regression cases to all specs
|
|
46
|
+
- tests: add more file-specific deserialize/serialize scenarios for custom, struct, map, resolving, and related schema behaviors
|
|
47
|
+
|
|
48
|
+
## 2026-02-17 - 1.2.5
|
|
49
|
+
|
|
50
|
+
- fix: stabilize ESLint for this repo by excluding AssemblyScript sources from standard TypeScript lint parsing
|
|
51
|
+
- fix: allow underscore-prefixed intentionally-unused TypeScript variables in transformer sources
|
|
52
|
+
- fix: add d8 globals for benchmark runner linting and make `bench/lib/bench.js` parseable by ESLint
|
|
53
|
+
|
|
54
|
+
## 2026-01-23 - 1.2.4
|
|
55
|
+
|
|
56
|
+
- fix: `Set<T>` and `StaticArray<T>` members in classes were not deserializing correctly
|
|
57
|
+
- fix: Fully reset state of transformer between builds
|
|
58
|
+
|
|
59
|
+
## 2026-01-03 - 1.2.3
|
|
60
|
+
|
|
61
|
+
- feat: handle surrogates and code units during string serialization and deserialization
|
|
62
|
+
- perf: add SWAR and SIMD string deserialization implementations
|
|
63
|
+
|
|
64
|
+
## 2025-12-23 - 1.2.2
|
|
65
|
+
|
|
66
|
+
- chore: reduce package size to sub 70kb
|
|
67
|
+
|
|
68
|
+
## 2025-12-23 - 1.2.1
|
|
69
|
+
|
|
70
|
+
- chore: fix chart link in readme
|
|
71
|
+
|
|
72
|
+
## 2025-12-23 - 1.2.0
|
|
73
|
+
|
|
74
|
+
- feat: Implement SWAR based algorithms, SIMD improvements, and better documentation.
|
|
75
|
+
|
|
76
|
+
## 2025-12-21 - 1.1.26
|
|
77
|
+
|
|
78
|
+
- chore: remove log
|
|
79
|
+
|
|
80
|
+
## 2025-12-21 - 1.1.25
|
|
81
|
+
|
|
82
|
+
- feat: Implement SWAR-based string serialization
|
|
83
|
+
|
|
84
|
+
## 2025-11-28 - 1.1.24
|
|
85
|
+
|
|
86
|
+
- feat: Implement a moving average window to determine buffer size (essentially, allow the buffer size to shrink) [#163](https://github.com/JairusSW/json-as/pull/163)
|
|
87
|
+
|
|
88
|
+
## 2025-11-06 - 1.1.23
|
|
89
|
+
|
|
90
|
+
- fix: Map keys should follow proper typing and quote rules [#161](https://github.com/JairusSW/json-as/issues/161)
|
|
91
|
+
|
|
92
|
+
## 2025-09-01 - 1.1.22
|
|
93
|
+
|
|
94
|
+
- fix: Type aliases should work across files [#154](https://github.com/JairusSW/json-as/issues/154)
|
|
95
|
+
|
|
96
|
+
## 2025-08-14 - 1.1.21
|
|
97
|
+
|
|
98
|
+
- fix: JSON.parse on classes with enums [#155](https://github.com/JairusSW/json-as/issues/155)
|
|
99
|
+
- fix: Resolve memory OOB issue within `serializeFloat` function [#153](https://github.com/JairusSW/json-as/issues/153)
|
|
100
|
+
|
|
101
|
+
## 2025-07-14 - 1.1.20
|
|
102
|
+
|
|
103
|
+
- feat: enable SIMD string serialization
|
|
104
|
+
|
|
105
|
+
## 2025-06-30 - 1.1.19
|
|
106
|
+
|
|
107
|
+
- fix: wrong path used in `readFileSync` when importing from a library
|
|
108
|
+
|
|
109
|
+
## 2025-06-30 - 1.1.18
|
|
110
|
+
|
|
111
|
+
- fix: [#150](https://github.com/JairusSW/json-as/issues/150)
|
|
112
|
+
|
|
113
|
+
## 2025-06-17 - 1.1.17
|
|
114
|
+
|
|
115
|
+
- fix: add support for classes within namespaces [#147](https://github.com/JairusSW/json-as/pull/147)
|
|
116
|
+
|
|
117
|
+
## 2025-06-12 - 1.1.16
|
|
118
|
+
|
|
119
|
+
- tests: properly support nulls (in testing lib)
|
|
120
|
+
- fix: initialize generic properties correctly
|
|
121
|
+
- fix: make generated imports compatible with windows
|
|
122
|
+
- feat: add support for fields marked with `readonly`
|
|
123
|
+
|
|
124
|
+
## 2025-06-09 - 1.1.15
|
|
125
|
+
|
|
126
|
+
- feat: add `.as<T>()` method to `JSON.Value`
|
|
127
|
+
- chore: remove all references to `__SERIALIZE_CUSTOM`
|
|
128
|
+
- feat: add support for `StaticArray` serialization
|
|
129
|
+
- feat: support `JSON.Raw` in array types
|
|
130
|
+
- tests: add tests for `JSON.Raw[]`
|
|
131
|
+
|
|
132
|
+
## 2025-05-29 - 1.1.14
|
|
133
|
+
|
|
134
|
+
- fix: hotfix schema resolver
|
|
135
|
+
|
|
136
|
+
## 2025-05-29 - 1.1.13
|
|
137
|
+
|
|
138
|
+
- fix: small issues with schema linking
|
|
139
|
+
- tests: add tests for schema linking and discovery
|
|
140
|
+
|
|
141
|
+
## 2025-05-29 - 1.1.12
|
|
142
|
+
|
|
143
|
+
- fix: add helpful warning on unknown or unaccessible types in fields
|
|
144
|
+
- feat: support deserialization of class generics
|
|
145
|
+
- fix: add support for numerical generics
|
|
146
|
+
- tests: add proper testing for generics
|
|
147
|
+
- feat: support type aliases with a custom type resolver/linker
|
|
148
|
+
- chore: add other linkers to tsconfig and clean up
|
|
149
|
+
- feat: add type alias resolving
|
|
150
|
+
|
|
151
|
+
## 2025-05-28 - 1.1.11
|
|
152
|
+
|
|
153
|
+
- fix: class resolving should only search top level statements for class declarations
|
|
154
|
+
- fix: add helpful error if class is missing an @json decorator
|
|
155
|
+
- fix: properly calculate relative path when json-as is a library
|
|
156
|
+
- fix: add proper null check when resolving imported classes
|
|
157
|
+
|
|
158
|
+
## 2025-05-28 - 1.1.10
|
|
159
|
+
|
|
160
|
+
- feat: add more debug levels (1 = print transform code, 2 = print keys/values at runtime)
|
|
161
|
+
- feat: add write out feature (`JSON_WRITE=path-to-file.ts`) which writes out generated code
|
|
162
|
+
- fix: complete full parity between port and original version for correct deserialization of all types
|
|
163
|
+
- feat: add proper schema resolution and dependency resolution
|
|
164
|
+
- feat: add proper type resolution to schema fields
|
|
165
|
+
- fix: properly calculate the relative path between imports to modules
|
|
166
|
+
|
|
167
|
+
## 2025-05-27 - 1.1.9
|
|
168
|
+
|
|
169
|
+
- change: strict mode is disabled by default. Enable it with JSON_STRICT=true
|
|
170
|
+
- fix: should ignore properties of same length and type if no matching key exists
|
|
171
|
+
- fix: should ignore properties of different type if no matching key exists
|
|
172
|
+
- fix: should ignore complex properties if no matching key exists
|
|
173
|
+
|
|
174
|
+
## 2025-05-27 - 1.1.8
|
|
175
|
+
|
|
176
|
+
- feat: add support for calling `JSON.stringify/JSON.parse` methods inside of custom serializers, but not yet deserializers
|
|
177
|
+
|
|
178
|
+
## 2025-05-27 - 1.1.7
|
|
179
|
+
|
|
180
|
+
- fix: bad boolean logic to decide whether to add 2nd break statement
|
|
181
|
+
|
|
182
|
+
## 2025-05-23 - 1.1.6
|
|
183
|
+
|
|
184
|
+
- fix: null and boolean fields would miscalculate offsets when deserializing
|
|
185
|
+
|
|
186
|
+
## 2025-05-23 - 1.1.5
|
|
187
|
+
|
|
188
|
+
- fix: index.js didn't point to correct file, thus creating a compiler crash
|
|
189
|
+
|
|
190
|
+
## 2025-05-23 - 1.1.4
|
|
191
|
+
|
|
192
|
+
- revert: grouping properties in favor of memory.compare
|
|
193
|
+
|
|
194
|
+
## 2025-05-23 - 1.1.3
|
|
195
|
+
|
|
196
|
+
- feat: group properties of structs before code generation
|
|
197
|
+
- fix: break out of switch case after completion
|
|
198
|
+
- ci: make compatible with act for local testing
|
|
199
|
+
|
|
200
|
+
## 2025-05-22 - 1.1.2
|
|
201
|
+
|
|
202
|
+
- fix: correct small typos in string value deserialization port
|
|
203
|
+
|
|
204
|
+
## 2025-05-22 - 1.1.1
|
|
205
|
+
|
|
206
|
+
- fix: remove random logs
|
|
207
|
+
|
|
208
|
+
## 2025-05-22 - 1.1.0
|
|
209
|
+
|
|
210
|
+
- fix: change _DESERIALIZE<T> to _JSON_T to avoid populating local scope
|
|
211
|
+
|
|
212
|
+
## 2025-05-22 - 1.0.9
|
|
213
|
+
|
|
214
|
+
- fix: [#132](https://github.com/JairusSW/json-as/issues/132)
|
|
215
|
+
- feat: allow base classes to use their child classes if the signatures match
|
|
216
|
+
- perf: rewrite struct deserialization to be significantly faster
|
|
217
|
+
- fix: [#131](https://github.com/JairusSW/json-as/issues/131) Generic classes with custom deserializer crashing
|
|
218
|
+
- fix: [#66](https://github.com/JairusSW/json-as/issues/66) Throw error when additional keys are in JSON
|
|
219
|
+
|
|
220
|
+
## 2025-05-21 - 1.0.8
|
|
221
|
+
|
|
222
|
+
- fix: inline warnings on layer-2 serialize and deserialize functions
|
|
223
|
+
- feat: fully support `JSON.Obj` and `JSON.Box` everywhere
|
|
224
|
+
- fix: temp disable SIMD
|
|
225
|
+
- feat: write fair benchmarks with `v8` using `jsvu`
|
|
226
|
+
|
|
227
|
+
## 2025-05-14 - 1.0.7
|
|
228
|
+
|
|
229
|
+
- merge: pull request [#128](https://github.com/JairusSW/json-as/pull/128) from [loredanacirstea/nested-custom-serializer-fix](https://github.com/loredanacirstea/nested-custom-serializer-fix)
|
|
230
|
+
|
|
231
|
+
## 2025-05-12 - 1.0.6
|
|
232
|
+
|
|
233
|
+
- fix: support zero-param serialization and make sure types are consistent
|
|
234
|
+
- fix: [#124](https://github.com/JairusSW/json-as/issues/124)
|
|
235
|
+
|
|
236
|
+
## 2025-05-11 - 1.0.5
|
|
237
|
+
|
|
238
|
+
- feat: add sanity checks for badly formatted strings
|
|
239
|
+
- fix: [#120](https://github.com/JairusSW/json-as/issues/120) handle empty `JSON.Obj` serialization
|
|
240
|
+
- feat: add SIMD optimization if SIMD is enabled by user
|
|
241
|
+
- fix: handle structs with nullable array as property [#123](https://github.com/JairusSW/json-as/pull/123)
|
|
242
|
+
- fix: struct serialization from writing to incorrect parts of memory when parsing nested structs [#125](https://github.com/JairusSW/json-as/pull/125)
|
|
243
|
+
- chore: add two new contributors
|
|
244
|
+
|
|
245
|
+
## 2025-04-07 - 1.0.4
|
|
246
|
+
|
|
247
|
+
- fix: paths must be resolved as POSIX in order to be valid TypeScript imports [#116](https://github.com/JairusSW/json-as/issues/116)
|
|
248
|
+
|
|
249
|
+
## 2025-03-24 - 1.0.3
|
|
250
|
+
|
|
251
|
+
- fix: make transform windows-compatible [#119](https://github.com/JairusSW/json-as/issues/119?reload=1)
|
|
252
|
+
|
|
253
|
+
## 2025-03-19 - 1.0.2
|
|
254
|
+
|
|
255
|
+
- fix: include check for nullable types for properties when deserialization is called internally [#118](https://github.com/JairusSW/json-as/pull/118)
|
|
256
|
+
|
|
257
|
+
## 2025-03-10 - 1.0.1
|
|
258
|
+
|
|
259
|
+
- docs: add comprehensive performance metrics
|
|
260
|
+
|
|
261
|
+
## 2025-03-09 - 1.0.0
|
|
262
|
+
|
|
263
|
+
- fix: relative paths pointing through node_modules would create a second Source
|
|
264
|
+
- feat: move behavior of `--lib` into transform itself
|
|
265
|
+
- fix: object with an object as a value containing a rhs bracket or brace would exit early [3b33e94](https://github.com/JairusSW/json-as/commit/3b33e9414dc04779d22d65272863372fcd7af4a6)
|
|
266
|
+
|
|
267
|
+
## 2025-03-04 - 1.0.0-beta.17
|
|
268
|
+
|
|
269
|
+
- fix: forgot to build transform
|
|
270
|
+
|
|
271
|
+
## 2025-03-04 - 1.0.0-beta.16
|
|
272
|
+
|
|
273
|
+
- fix: isPrimitive should only trigger on actual primitives
|
|
274
|
+
|
|
275
|
+
## 2025-03-04 - 1.0.0-beta.15
|
|
276
|
+
|
|
277
|
+
- fix: deserialize custom should take in string
|
|
278
|
+
|
|
279
|
+
## 2025-03-04 - 1.0.0-beta.14
|
|
280
|
+
|
|
281
|
+
- fix: reference to nonexistent variable during custom deserialization layer 2
|
|
282
|
+
|
|
283
|
+
## 2025-03-04 - 1.0.0-beta.13
|
|
284
|
+
|
|
285
|
+
- fix: forgot to actually build the transform
|
|
286
|
+
|
|
287
|
+
## 2025-03-04 - 1.0.0-beta.12
|
|
288
|
+
|
|
289
|
+
- fix: build transform
|
|
290
|
+
|
|
291
|
+
## 2025-03-04 - 1.0.0-beta.11
|
|
292
|
+
|
|
293
|
+
- fix: wrongly assumed pointer types within arbitrary deserialization
|
|
294
|
+
- fix: wrong pointer type being passed during map deserialization
|
|
295
|
+
|
|
296
|
+
## 2025-03-04 - 1.0.0-beta.10
|
|
297
|
+
|
|
298
|
+
- fix: transform not generating the right load operations for keys
|
|
299
|
+
- fix: whitespace not working in objects or struct deserialization
|
|
300
|
+
- fix: JSON.Raw not working when deserializing as Map<string, JSON.Raw>
|
|
301
|
+
|
|
302
|
+
## 2025-03-03 - 1.0.0-beta.9
|
|
303
|
+
|
|
304
|
+
- rename: change libs folder to lib
|
|
305
|
+
|
|
306
|
+
## 2025-03-03 - 1.0.0-beta.8
|
|
307
|
+
|
|
308
|
+
- docs: add instructions for using `--lib` in README
|
|
309
|
+
|
|
310
|
+
## 2025-03-03 - 1.0.0-beta.7
|
|
311
|
+
|
|
312
|
+
- fix: add as-bs to `--lib` section
|
|
313
|
+
- chore: clean up transform
|
|
314
|
+
- refactor: transform should import `~lib/as-bs.ts` instead of relative path
|
|
315
|
+
|
|
316
|
+
## 2025-03-01 - 1.0.0-beta.6
|
|
317
|
+
|
|
318
|
+
- fix: import from base directory index.ts
|
|
319
|
+
|
|
320
|
+
## 2025-03-01 - 1.0.0-beta.5
|
|
321
|
+
|
|
322
|
+
- fix: revert pull request [#112](https://github.com/JairusSW/json-as/pull/112)
|
|
323
|
+
|
|
324
|
+
## 2025-02-25 - 1.0.0-beta.4
|
|
325
|
+
|
|
326
|
+
- fix: warn on presence of invalid types contained in a schema [#112](https://github.com/JairusSW/json-as/pull/112)
|
|
327
|
+
|
|
328
|
+
## 2025-02-25 - 1.0.0-beta.3
|
|
329
|
+
|
|
330
|
+
- feat: change `JSON.Raw` to actual class to facilitate proper support without transformations
|
|
331
|
+
- fix: remove old `JSON.Raw` logic from transform code
|
|
332
|
+
|
|
333
|
+
## 2025-02-25 - 1.0.0-beta.2
|
|
334
|
+
|
|
335
|
+
- feat: add support for custom serializers and deserializers [#110](https://github.com/JairusSW/json-as/pull/110)
|
|
336
|
+
|
|
337
|
+
## 2025-02-22 - 1.0.0-beta.1
|
|
338
|
+
|
|
339
|
+
- perf: add benchmarks for both AssemblyScript and JavaScript
|
|
340
|
+
- docs: publish preliminary benchmark results
|
|
341
|
+
- tests: ensure nested serialization works and add to tests
|
|
342
|
+
- feat: finish arbitrary type implementation
|
|
343
|
+
- feat: introduce `JSON.Obj` to handle objects effectively
|
|
344
|
+
- feat: reimplement arbitrary array deserialization
|
|
345
|
+
- fix: remove brace check on array deserialization
|
|
346
|
+
- feat: introduce native support for `JSON.Obj` transformations
|
|
347
|
+
- feat: implement arbitrary object serialization
|
|
348
|
+
- fix: deserialization of booleans panics on `false`
|
|
349
|
+
- fix: `bs.resize` should be type-safe
|
|
350
|
+
- impl: add `JSON.Obj` type as prototype to handle arbitrary object structures
|
|
351
|
+
- chore: rename static objects (schemas) to structs and name arbitrary objects as `obj`
|
|
352
|
+
- tests: add proper tests for arbitrary types
|
|
353
|
+
- fix: empty method generation using outdated function signature
|
|
354
|
+
- docs: update readme to be more concise
|
|
355
|
+
|
|
356
|
+
## 2025-02-13 - 1.0.0-alpha.4
|
|
357
|
+
|
|
358
|
+
- feat: reintroduce support for `Box<T>`-wrapped primitive types
|
|
359
|
+
- tests: add extensive tests to all supported types
|
|
360
|
+
- fix: 6-byte keys being recognized on deserialize
|
|
361
|
+
- perf: take advantage of aligned memory to use a single 64-bit load on 6-byte keys
|
|
362
|
+
- fix: `bs.proposeSize()` should increment `stackSize` by `size` instead of setting it
|
|
363
|
+
- fix: allow runtime to manage `bs.buffer`
|
|
364
|
+
- fix: memory leaks in `bs` module
|
|
365
|
+
- fix: add (possibly temporary) `JSON.Memory.shrink()` to shrink memory in `bs`
|
|
366
|
+
- perf: prefer growing memory by `nextPowerOf2(size + 64)` for less reallocations
|
|
367
|
+
- tests: add boolean tests to `Box<T>`
|
|
368
|
+
- fix: serialization of non-growable data types should grow `bs.stackSize`
|
|
369
|
+
|
|
370
|
+
## 2025-01-31 - 1.0.0-alpha.3
|
|
371
|
+
|
|
372
|
+
- fix: write to proper offset when deserializing string with \u0000-type escapes
|
|
373
|
+
- fix: simplify and fix memory offset issues with bs module
|
|
374
|
+
- fix: properly predict minimum size of to-be-serialized schemas
|
|
375
|
+
- fix: replace as-test with temporary framework to mitigate json-as versioning issues
|
|
376
|
+
- fix: fix multiple memory leaks during serialization
|
|
377
|
+
- feat: align memory allocations for better performance
|
|
378
|
+
- feat: achieve a space complexity of O(n) for serialization operations, unless dealing with \u0000-type escapes
|
|
379
|
+
|
|
380
|
+
## 2025-01-20 - 1.0.0-alpha.2
|
|
381
|
+
|
|
382
|
+
- fix: disable SIMD in generated transform code by default
|
|
383
|
+
- fix: re-add as-bs dependency so that it will not break in non-local environments
|
|
384
|
+
- fix: remove AS201 'conversion from type usize to i32' warning
|
|
385
|
+
- fix: add as-bs to peer dependencies so only one version is installed
|
|
386
|
+
- fix: point as-bs imports to submodule
|
|
387
|
+
- fix: remove submodule in favor of static module
|
|
388
|
+
- fix: bs.ensureSize would not grow and thus cause memory faults
|
|
389
|
+
- fix: bs.ensureSize triggering unintentionally
|
|
390
|
+
|
|
391
|
+
## 2025-01-20 - 1.0.0-alpha.1
|
|
392
|
+
|
|
393
|
+
- feat: finish implementation of arbitrary data serialization and deserialization using JSON.Value
|
|
394
|
+
- feat: reinstate usage of `JSON.Box<T>()` to support nullable primitive types
|
|
395
|
+
- feat: eliminate the need to import the `JSON` namespace when defining a schema
|
|
396
|
+
- feat: reduce memory usage so that it is viable for low-memory environments
|
|
397
|
+
- feat: write to a central buffer and reduce memory overhead
|
|
398
|
+
- feat: rewrite the transform to properly resolve schemas and link them together
|
|
399
|
+
- feat: pre-allocate and compute the minimum size of a schema to avoid memory out of range errors
|
|
400
|
+
>>>>>>> cf237fa (chore: release 1.3.0)
|
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<summary>Table of Contents</summary>
|
|
7
7
|
|
|
8
8
|
- [Installation](#installation)
|
|
9
|
+
- [Docs](#docs)
|
|
9
10
|
- [Usage](#usage)
|
|
10
11
|
- [Examples](#examples)
|
|
11
12
|
- [Omitting Fields](#omitting-fields)
|
|
@@ -14,9 +15,12 @@
|
|
|
14
15
|
- [Using Raw JSON Strings](#using-raw-json-strings)
|
|
15
16
|
- [Working with Enums](#working-with-enums)
|
|
16
17
|
- [Using Custom Serializers or Deserializers](#using-custom-serializers-or-deserializers)
|
|
18
|
+
- [Overriding built-in Container Types](#overriding-built-in-container-types)
|
|
17
19
|
- [Performance](#performance)
|
|
18
20
|
- [Comparison to JavaScript](#comparison-to-javascript)
|
|
19
21
|
- [Performance Tuning](#performance-tuning)
|
|
22
|
+
- [Fast-Path Compatibility Matrix](#fast-path-compatibility-matrix)
|
|
23
|
+
- [Container Compatibility Matrix](#container-compatibility-matrix)
|
|
20
24
|
- [Running Benchmarks Locally](#running-benchmarks-locally)
|
|
21
25
|
- [Debugging](#debugging)
|
|
22
26
|
- [Architecture](#architecture)
|
|
@@ -57,6 +61,12 @@ Alternatively, add it to your `asconfig.json`
|
|
|
57
61
|
|
|
58
62
|
If you'd like to see the code that the transform generates, run the build step with `DEBUG=true`
|
|
59
63
|
|
|
64
|
+
## Docs
|
|
65
|
+
|
|
66
|
+
Full documentation lives at:
|
|
67
|
+
|
|
68
|
+
<https://docs.jairus.dev/json-as>
|
|
69
|
+
|
|
60
70
|
## Usage
|
|
61
71
|
|
|
62
72
|
```typescript
|
|
@@ -334,11 +344,11 @@ const serialized = JSON.stringify<Foo>(Foo.bar);
|
|
|
334
344
|
|
|
335
345
|
This library supports custom serialization and deserialization methods, which can be defined using the `@serializer` and `@deserializer` decorators.
|
|
336
346
|
|
|
337
|
-
|
|
347
|
+
Custom serializers and deserializers must always speak valid JSON. You can optionally provide the JSON value shape they operate on using one of: `"any"`, `"string"`, `"number"`, `"object"`, `"array"`, `"boolean"`, or `"null"`. If omitted, the shape defaults to `"any"`.
|
|
338
348
|
|
|
339
|
-
|
|
340
|
-
import { bytes } from "json-as/assembly/util";
|
|
349
|
+
Here's an example of creating a custom data type called `Point` which serializes to a JSON string:
|
|
341
350
|
|
|
351
|
+
```typescript
|
|
342
352
|
@json
|
|
343
353
|
class Point {
|
|
344
354
|
x: f64 = 0.0;
|
|
@@ -348,21 +358,21 @@ class Point {
|
|
|
348
358
|
this.y = y;
|
|
349
359
|
}
|
|
350
360
|
|
|
351
|
-
@serializer
|
|
361
|
+
@serializer("string")
|
|
352
362
|
serializer(self: Point): string {
|
|
353
|
-
return
|
|
363
|
+
return JSON.stringify(`${self.x},${self.y}`);
|
|
354
364
|
}
|
|
355
365
|
|
|
356
|
-
@deserializer
|
|
366
|
+
@deserializer("string")
|
|
357
367
|
deserializer(data: string): Point {
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
368
|
+
const raw = JSON.parse<string>(data);
|
|
369
|
+
if (!raw.length) throw new Error("Could not deserialize provided data as type Point");
|
|
360
370
|
|
|
361
|
-
const c =
|
|
362
|
-
const x =
|
|
363
|
-
const y =
|
|
371
|
+
const c = raw.indexOf(",");
|
|
372
|
+
const x = raw.slice(0, c);
|
|
373
|
+
const y = raw.slice(c + 1);
|
|
364
374
|
|
|
365
|
-
return new Point(f64.parse(x), f64.parse(y));
|
|
375
|
+
return new Point(f64.parse(x), f64.parse(y)); // NEVER use this in deserializers. Always return a new instance
|
|
366
376
|
}
|
|
367
377
|
}
|
|
368
378
|
|
|
@@ -375,9 +385,11 @@ console.log("Serialized " + serialized);
|
|
|
375
385
|
console.log("Deserialized " + JSON.stringify(deserialized));
|
|
376
386
|
```
|
|
377
387
|
|
|
378
|
-
The serializer function converts a `Point` instance into a string
|
|
388
|
+
The serializer function converts a `Point` instance into a valid JSON string value.
|
|
389
|
+
|
|
390
|
+
The deserializer function parses that JSON string back into a `Point` instance.
|
|
379
391
|
|
|
380
|
-
|
|
392
|
+
Custom deserializers should always instantiate and return a new object. They should not assume an existing destination instance will be passed in or reused.
|
|
381
393
|
|
|
382
394
|
These functions are then wrapped before being consumed by the json-as library:
|
|
383
395
|
|
|
@@ -396,6 +408,85 @@ These functions are then wrapped before being consumed by the json-as library:
|
|
|
396
408
|
|
|
397
409
|
This allows custom serialization while maintaining a generic interface for the library to access.
|
|
398
410
|
|
|
411
|
+
### Overriding built-in container types
|
|
412
|
+
|
|
413
|
+
Undecorated subclasses of built-in container types keep the built-in JSON behavior.
|
|
414
|
+
|
|
415
|
+
This rule applies consistently across:
|
|
416
|
+
|
|
417
|
+
- `JSON.stringify(...)`
|
|
418
|
+
- `JSON.parse<T>(...)`
|
|
419
|
+
- `JSON.Value.from(...)`
|
|
420
|
+
- `JSON.internal.stringify(...)`
|
|
421
|
+
- `JSON.internal.parse(...)`
|
|
422
|
+
|
|
423
|
+
For example:
|
|
424
|
+
|
|
425
|
+
- `class MyBytes extends Uint8Array {}` still serializes like a normal `Uint8Array`
|
|
426
|
+
- `class MyMap extends Map<string, i32> {}` still serializes like a normal `Map<string, i32>`
|
|
427
|
+
- the same applies to subclassable built-ins such as `Array`, `Set`, and typed arrays
|
|
428
|
+
|
|
429
|
+
If you decorate that subclass with `@json`, it is treated as a normal generated class instead of inheriting the built-in container behavior. That means generated `__SERIALIZE` / `__DESERIALIZE` logic and custom serializer/deserializer hooks can take over.
|
|
430
|
+
|
|
431
|
+
If you want a different wire format, decorate the subclass with `@json` and provide custom `@serializer(...)` / `@deserializer(...)` methods:
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
function hexDigit(value: u8): string {
|
|
435
|
+
return String.fromCharCode(value < 10 ? 48 + value : 87 + value);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function parseHexNibble(code: u16): u8 {
|
|
439
|
+
if (code >= 48 && code <= 57) return <u8>(code - 48);
|
|
440
|
+
if (code >= 97 && code <= 102) return <u8>(code - 87);
|
|
441
|
+
return <u8>(code - 55);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
@json
|
|
445
|
+
class HexBytes extends Uint8Array {
|
|
446
|
+
constructor(length: i32 = 0) {
|
|
447
|
+
super(length);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
@serializer("string")
|
|
451
|
+
serializer(self: HexBytes): string {
|
|
452
|
+
let out = "";
|
|
453
|
+
for (let i = 0; i < self.length; i++) {
|
|
454
|
+
const value = unchecked(self[i]);
|
|
455
|
+
out += hexDigit(value >> 4);
|
|
456
|
+
out += hexDigit(value & 0x0f);
|
|
457
|
+
}
|
|
458
|
+
return JSON.stringify(out);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
@deserializer("string")
|
|
462
|
+
deserializer(data: string): HexBytes {
|
|
463
|
+
const raw = JSON.parse<string>(data);
|
|
464
|
+
const out = new HexBytes(raw.length >> 1);
|
|
465
|
+
|
|
466
|
+
for (let i = 0, j = 0; i < raw.length; i += 2, j++) {
|
|
467
|
+
const hi = parseHexNibble(<u16>raw.charCodeAt(i));
|
|
468
|
+
const lo = parseHexNibble(<u16>raw.charCodeAt(i + 1));
|
|
469
|
+
unchecked((out[j] = <u8>((hi << 4) | lo)));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
return out;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const bytes = new HexBytes(4);
|
|
477
|
+
bytes[0] = 10;
|
|
478
|
+
bytes[1] = 20;
|
|
479
|
+
bytes[2] = 30;
|
|
480
|
+
bytes[3] = 40;
|
|
481
|
+
|
|
482
|
+
JSON.stringify(bytes); // "\"0a141e28\""
|
|
483
|
+
JSON.parse<HexBytes>("\"0a141e28\"");
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
This same pattern works for subclassable built-ins like `Array`, `Map`, `Set`, and typed arrays.
|
|
487
|
+
|
|
488
|
+
`ArrayBuffer` and `String` are `@final` in AssemblyScript, so they cannot be subclassed there.
|
|
489
|
+
|
|
399
490
|
## Performance
|
|
400
491
|
|
|
401
492
|
The `json-as` library is engineered for **multi-GB/s processing speeds**, leveraging SIMD and SWAR optimizations along with highly efficient transformations. The charts below highlight key performance metrics such as build time, operations-per-second, and throughput.
|
|
@@ -414,14 +505,38 @@ The following charts compare JSON-AS (both SWAR and SIMD variants) against JavaS
|
|
|
414
505
|
|
|
415
506
|
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart02.svg" alt="Performance Chart 2">
|
|
416
507
|
|
|
508
|
+
<details>
|
|
509
|
+
<summary>String serialize charts (click to expand)</summary>
|
|
510
|
+
|
|
417
511
|
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart03.png" alt="Performance Chart 3">
|
|
418
512
|
|
|
513
|
+
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart07.png" alt="Performance Chart 7">
|
|
514
|
+
</details>
|
|
515
|
+
|
|
516
|
+
<details>
|
|
517
|
+
<summary>String deserialize charts (click to expand)</summary>
|
|
518
|
+
|
|
419
519
|
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart04.png" alt="Performance Chart 4">
|
|
420
520
|
|
|
521
|
+
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart08.png" alt="Performance Chart 8">
|
|
522
|
+
</details>
|
|
523
|
+
|
|
524
|
+
<details>
|
|
525
|
+
<summary>Object serialize charts (click to expand)</summary>
|
|
526
|
+
|
|
421
527
|
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart05.png" alt="Performance Chart 5">
|
|
422
528
|
|
|
529
|
+
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart09.png" alt="Performance Chart 9">
|
|
530
|
+
</details>
|
|
531
|
+
|
|
532
|
+
<details>
|
|
533
|
+
<summary>Object deserialize charts (click to expand)</summary>
|
|
534
|
+
|
|
423
535
|
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart06.png" alt="Performance Chart 6">
|
|
424
536
|
|
|
537
|
+
<img src="https://raw.githubusercontent.com/JairusSW/json-as/refs/heads/docs/charts/chart10.png" alt="Performance Chart 10">
|
|
538
|
+
</details>
|
|
539
|
+
|
|
425
540
|
### Performance Tuning
|
|
426
541
|
|
|
427
542
|
Instead of using flags for setting options, `json-as` is configured by environmental variables.
|
|
@@ -433,7 +548,7 @@ Here's a short list:
|
|
|
433
548
|
|
|
434
549
|
**JSON_MODE** (default: SWAR) - Selects which mode should be used. Can be `NAIVE,SWAR,SIMD`. Note that `--enable simd` may be required.
|
|
435
550
|
|
|
436
|
-
**JSON_USE_FAST_PATH** (default: 0) - When set to `1`, the transform emits the fast `__DESERIALIZE` implementation for generated structs. When unset or `0`, it emits only the slow path.
|
|
551
|
+
**JSON_USE_FAST_PATH** (default: 0) - When set to `1`, the transform emits the fast `__DESERIALIZE` implementation for generated structs. When unset or `0`, it emits only the slow path. See [FAST_PATH_DESERIALIZE.md](./FAST_PATH_DESERIALIZE.md) for the current support matrix, known gaps, and dedicated test command.
|
|
437
552
|
|
|
438
553
|
**JSON_WRITE** (default: "") - Select a series of files to output after transform and optimization passes have completed for easy inspection. Usage: `JSON_WRITE=.path-to-file-a.ts,./path-to-file-b.ts`
|
|
439
554
|
|
|
@@ -464,32 +579,20 @@ npm install
|
|
|
464
579
|
4. Run either benchmark suite directly:
|
|
465
580
|
|
|
466
581
|
```bash
|
|
467
|
-
|
|
468
|
-
|
|
582
|
+
npm run bench:as
|
|
583
|
+
npm run bench:js
|
|
469
584
|
```
|
|
470
585
|
|
|
471
586
|
5. Build charts from the latest local logs:
|
|
472
587
|
|
|
473
588
|
```bash
|
|
474
|
-
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
6. Publish benchmark charts to the `docs` branch:
|
|
478
|
-
|
|
479
|
-
```bash
|
|
480
|
-
./publish-benchmarks.sh
|
|
589
|
+
npm run charts:build
|
|
481
590
|
```
|
|
482
591
|
|
|
483
|
-
|
|
592
|
+
Or run the full local benchmark flow in one step:
|
|
484
593
|
|
|
485
594
|
```bash
|
|
486
|
-
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
Or run the full local publish flow in one step:
|
|
490
|
-
|
|
491
|
-
```bash
|
|
492
|
-
npm run bench:publish
|
|
595
|
+
npm run bench
|
|
493
596
|
```
|
|
494
597
|
|
|
495
598
|
## Debugging
|
|
@@ -502,6 +605,8 @@ npm run bench:publish
|
|
|
502
605
|
|
|
503
606
|
For a deep dive into how json-as works internally, including the transform system, optimization modes (NAIVE, SWAR, SIMD), and buffer management, see [ARCHITECTURE.md](./ARCHITECTURE.md).
|
|
504
607
|
|
|
608
|
+
For a code-oriented repository walkthrough that maps the runtime, transform, tests, and benchmark files to their concrete responsibilities, see [PROJECT_WALKTHROUGH.md](./PROJECT_WALKTHROUGH.md).
|
|
609
|
+
|
|
505
610
|
## Contributing
|
|
506
611
|
|
|
507
612
|
We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSON } from "../..";
|
|
2
2
|
import { deserializeArray } from "./array";
|
|
3
3
|
import { deserializeBoolean } from "./bool";
|
|
4
|
-
import { deserializeFloat } from "
|
|
4
|
+
import { deserializeFloat } from "../simple/float";
|
|
5
5
|
import { deserializeObject } from "./object";
|
|
6
6
|
import { deserializeString } from "./string";
|
|
7
7
|
import { BRACE_LEFT, BRACKET_LEFT, CHAR_N, QUOTE } from "../../custom/chars";
|