Skip to content

Commit 67dcfb5

Browse files
committed
fix: serialize plain null
1 parent 2fedb06 commit 67dcfb5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

assembly/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export namespace JSON {
4343
* @param data T
4444
* @returns string
4545
*/
46-
export function stringify<T extends Nullable | null>(data: T, out: string | null = null): string {
46+
export function stringify<T>(data: T, out: string | null = null): string {
4747
if (isBoolean<T>(data)) {
4848
if (out) {
4949
if (<bool>data == true) {
@@ -57,6 +57,13 @@ export namespace JSON {
5757
return out;
5858
}
5959
return out ? "true" : "false";
60+
} else if (isInteger<T>() && nameof<T>() == "usize" && data == 0) {
61+
if (out) {
62+
out = changetype<string>(__renew(changetype<usize>(out), 8));
63+
store<u64>(changetype<usize>(out), 30399761348886638);
64+
return out;
65+
}
66+
return NULL_WORD;
6067
} else if (isInteger<T>(data)) {
6168
if (out) {
6269
out = changetype<string>(__renew(changetype<usize>(out), sizeof<T>() << 3));

0 commit comments

Comments
 (0)