Skip to content

Commit d7321c2

Browse files
committed
release: v1.1.21
1 parent 7c01fe6 commit d7321c2

11 files changed

Lines changed: 33 additions & 29 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## [Unreleased]
3+
## 2025-08-14 - 1.1.21
44

55
- fix: JSON.parse on classes with enums [#155](https://github.com/JairusSW/json-as/issues/155)
66
- fix: Resolve memory OOB issue within `serializeFloat` function [#153](https://github.com/JairusSW/json-as/issues/153)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<h1 align="center"><pre> ╦╔═╗╔═╗╔╗╔ ╔═╗╔═╗
2-
║╚═╗║ ║║║║═╠═╣╚═╗
3-
╚╝╚═╝╚═╝╝╚╝ ╩ ╩╚═╝</pre></h1>
1+
<h1 align="center"><pre> ╦╔═╗╔═╗╔╗╔ ╔═╗╔═╗
2+
║╚═╗║ ║║║║═╠═╣╚═╗
3+
╚╝╚═╝╚═╝╝╚╝ ╩ ╩╚═╝</pre></h1>
44

55
## 💾 Installation
66

assembly/__tests__/arbitrary.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ describe("Should serialize arbitrary types", () => {
2323
o.get("properties")!.as<JSON.Obj>().get("steps")!.as<JSON.Obj>().set("type", "number");
2424
o.set("type", "object");
2525

26-
expect(o.toString())
27-
.toBe('{"schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"duration":{"default":10.0,"description":"Duration of the operation in seconds","type":"number"},"steps":{"default":5.0,"description":"Number of steps in the operation","type":"number"}},"type":"object"}');
26+
expect(o.toString()).toBe('{"schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"duration":{"default":10.0,"description":"Duration of the operation in seconds","type":"number"},"steps":{"default":5.0,"description":"Number of steps in the operation","type":"number"}},"type":"object"}');
2827
});
2928

3029
describe("Should deserialize arbitrary types", () => {
@@ -33,4 +32,4 @@ describe("Should deserialize arbitrary types", () => {
3332
expect(JSON.parse<JSON.Value>("true").toString()).toBe("true");
3433
expect(JSON.stringify(JSON.parse<JSON.Value>('{"x":1.0,"y":2.0,"z":3.0}'))).toBe('{"x":1.0,"y":2.0,"z":3.0}');
3534
expect(JSON.stringify(JSON.parse<JSON.Value[]>('["string",true,3.14,{"x":1.0,"y":2.0,"z":3.0},[1.0,2.0,3,true]]'))).toBe('["string",true,3.14,{"x":1.0,"y":2.0,"z":3.0},[1.0,2.0,3.0,true]]');
36-
});
35+
});

assembly/__tests__/enum.spec.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,32 @@ import { JSON } from "..";
22
import { describe, expect } from "./lib";
33

44
enum Enum1 {
5-
Zero = 0,
6-
One = 1,
7-
Two = 2,
8-
Three = 3,
5+
Zero = 0,
6+
One = 1,
7+
Two = 2,
8+
Three = 3,
99
}
1010

11+
1112
@json
1213
class DataWithEnum {
13-
v: Enum1 = Enum1.One
14-
constructor(v: Enum1) {
15-
this.v = v
16-
}
14+
v: Enum1 = Enum1.One;
15+
constructor(v: Enum1) {
16+
this.v = v;
17+
}
1718
}
1819

1920
describe("Should serialize enums", () => {
20-
expect(JSON.stringify<Enum1>(Enum1.One)).toBe('1');
21-
expect(JSON.stringify<Enum1>(Enum1.Zero)).toBe('0');
21+
expect(JSON.stringify<Enum1>(Enum1.One)).toBe("1");
22+
expect(JSON.stringify<Enum1>(Enum1.Zero)).toBe("0");
2223
expect(JSON.stringify<DataWithEnum>(new DataWithEnum(Enum1.Two))).toBe('{"v":2}');
2324
});
2425

2526
describe("Should deserialize enums", () => {
26-
const date1 = JSON.parse<Enum1>('2');
27+
const date1 = JSON.parse<Enum1>("2");
2728
expect(date1).toBe(Enum1.Two);
2829

29-
const date2 = JSON.parse<Enum1>('0');
30+
const date2 = JSON.parse<Enum1>("0");
3031
expect(date2).toBe(Enum1.Zero);
3132

3233
const date3 = JSON.parse<DataWithEnum>('{"v":3}');

assembly/deserialize/simd/string.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { DESERIALIZE_ESCAPE_TABLE, ESCAPE_HEX_TABLE } from "../../globals/tables
1010
// todo: optimize and stuff. it works, its not pretty. ideally, i'd like this to be (nearly) branchless
1111
export function deserializeString_SIMD(srcStart: usize, srcEnd: usize, dst: usize): usize {
1212
const SPLAT_92 = i16x8.splat(92); /* \ */
13-
srcStart += 2; srcEnd -= 2;
13+
srcStart += 2;
14+
srcEnd -= 2;
1415
let dst_ptr = changetype<usize>(dst);
1516
const src_end_15 = srcEnd - 15;
1617

assembly/deserialize/simple/arbitrary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ export function deserializeArbitrary(srcStart: usize, srcEnd: usize, dst: usize)
1818
return JSON.Value.from<usize>(0);
1919
}
2020
return unreachable();
21-
}
21+
}

assembly/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export namespace JSON {
260260
}
261261
}
262262

263+
263264
@final
264265
export class Value {
265266
static METHODS: Map<u32, u32> = new Map<u32, u32>();
@@ -421,6 +422,7 @@ export namespace JSON {
421422
}
422423
}
423424

425+
424426
@unsafe private __visit(cookie: u32): void {
425427
if (this.type >= JSON.Types.String) {
426428
__visit(load<usize>(changetype<usize>(this), STORAGE), cookie);
@@ -432,7 +434,7 @@ export namespace JSON {
432434
// @ts-ignore: type
433435
storage: Map<string, JSON.Value> = new Map<string, JSON.Value>();
434436

435-
constructor() { }
437+
constructor() {}
436438

437439
// @ts-ignore: decorator
438440
@inline get size(): i32 {

assembly/test.tmp.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import {
2-
JSON
3-
} from ".";
1+
import { JSON } from ".";
42
const o = new JSON.Obj();
53
o.set("schema", "http://json-schema.org/draft-07/schema#");
64
o.set("additionalProperties", false);

assembly/test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { JSON } from ".";
22

3+
34
@json
45
class Vec3 {
56
x: f32 = 0.0;
67
y: f32 = 0.0;
78
z: f32 = 0.0;
89
}
910

11+
1012
@json
1113
class Player {
14+
1215
@alias("first name")
1316
firstName!: string | null;
1417
lastName!: string;
@@ -38,4 +41,4 @@ const serialized = JSON.stringify<Player>(player);
3841
const deserialized = JSON.parse<Player>(serialized);
3942

4043
console.log("Serialized " + serialized);
41-
console.log("Deserialized " + JSON.stringify(deserialized));
44+
console.log("Deserialized " + JSON.stringify(deserialized));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-as",
3-
"version": "1.1.20",
3+
"version": "1.1.21",
44
"author": "Jairus Tanaka",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)