Skip to content

Commit

Permalink
fix: serialize plain null
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jan 8, 2025
1 parent 2fedb06 commit 67dcfb5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export namespace JSON {
* @param data T
* @returns string
*/
export function stringify<T extends Nullable | null>(data: T, out: string | null = null): string {
export function stringify<T>(data: T, out: string | null = null): string {
if (isBoolean<T>(data)) {
if (out) {
if (<bool>data == true) {
Expand All @@ -57,6 +57,13 @@ export namespace JSON {
return out;
}
return out ? "true" : "false";
} else if (isInteger<T>() && nameof<T>() == "usize" && data == 0) {
if (out) {
out = changetype<string>(__renew(changetype<usize>(out), 8));
store<u64>(changetype<usize>(out), 30399761348886638);
return out;
}
return NULL_WORD;
} else if (isInteger<T>(data)) {
if (out) {
out = changetype<string>(__renew(changetype<usize>(out), sizeof<T>() << 3));
Expand Down

0 comments on commit 67dcfb5

Please sign in to comment.