-
Notifications
You must be signed in to change notification settings - Fork 2
@Data, ToJson(), FromJson(), fix a nullability annotation
#6
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -341,9 +341,37 @@ uriencode(undefined()) ⇶ undefined() | |
| uriencode('') ⇶ '' | ||
| uriencode(' ') ⇶ '%20' | ||
|
|
||
| // JSON serialization | ||
| tojson(42) ⇶ '42' | ||
| tojson('a') ⇶ '"a"' | ||
| tojson(true) ⇶ 'true' | ||
| tojson(null) ⇶ 'null' | ||
| tojson(undefined()) ⇶ undefined() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undefined is not a function
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 that's the convention we've used for some time in these tests; we could use |
||
| tojson([1, 'b', null]) ⇶ '[1,"b",null]' | ||
| tojson({a: 1}) ⇶ '{"a":1}' | ||
| tojson(@Level) ⇶ '"Information"' | ||
|
|
||
| // JSON deserialization | ||
| fromjson('{"a": [1, null, "x"]}') ⇶ {a: [1, null, 'x']} | ||
| fromjson(' true ') ⇶ true | ||
| fromjson('null') ⇶ null | ||
| fromjson('') ⇶ undefined() | ||
| fromjson('{"a":') ⇶ undefined() | ||
| fromjson(42) ⇶ undefined() | ||
| fromjson(null) ⇶ undefined() | ||
| fromjson(undefined()) ⇶ undefined() | ||
| fromjson(tojson({a: [1, 'b']})) ⇶ {a: [1, 'b']} | ||
|
|
||
| tostring(@Level, 'u3') ⇶ 'INF' | ||
| tostring(@Elapsed) ⇶ '00:10:00' | ||
|
|
||
| // The whole event document via @Data (@Document is deprecated and thus left undefined). | ||
| @Data['@mt'] ⇶ @mt | ||
| @Data['User']['Name'] ⇶ 'nblumhardt' | ||
| @Data['@Nonexistent'] ⇶ undefined() | ||
| @Document ⇶ undefined() | ||
| @Arrived ⇶ undefined() | ||
|
|
||
| // Typed values keep their string forms when inserted into constructed containers | ||
| [@Level][0] ⇶ 'Information' | ||
| {l: @Level}['l'] ⇶ 'Information' | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JsonNode is already JSON
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JsonNode?is the object type - i.e. you might get aJsonArrayetc. there. The function converts whatever object it's given into a raw JSON string 👍