Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve warning in deserializeRawMap #692

Merged
merged 6 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## UNRELEASED

- fix: resolve warning in `deserializeRawMap` [#692](https://github.com/hypermodeinc/modus/pull/692)

## 2025-01-07 - CLI 0.16.4

No changes. Re-released previous version to fix release issue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class Obj {
foo: string = "";
}

it("should handle nulls correctly", () => {
const m1 = JSON.parse<DynamicMap>('{"a":null}');
const m2 = new DynamicMap();
m2.set("a", null);

expect(JSON.stringify(m1)).toBe('{"a":null}');
expect(JSON.stringify(m2)).toBe('{"a":null}');
});

it("should parse complex values", () => {
const input =
'{"a":{"b":{"c":[{"d":"random value 1"},{"e":["value 2","value 3"]}],"f":{"g":{"h":[1,2,3],"i":{"j":"nested value"}}}},"k":"simple value"},"l":[{"m":"another value","n":{"o":"deep nested","p":[{"q":"even deeper"},"final value"]}}],"r":null}';
Expand Down
2 changes: 1 addition & 1 deletion sdk/assemblyscript/src/assembly/dynamicmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class DynamicMap {
}

public set<T>(key: string, value: T): void {
if (value == null) {
if (isInteger<T>() && nameof<T>() == "usize" && value == 0) {
this.data.set(key, "null");
} else {
this.data.set(key, JSON.stringify(value));
Expand Down
Loading