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

lib: fix json_encode for null values #44

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion lib/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ var (
types.IntType: reflectInt64Type,
types.ListType: reflect.TypeOf([]interface{}(nil)),
types.MapType: reflectMapStringAnyType,
types.NullType: reflect.TypeOf((*int)(nil)), // Any pointer will do.
types.StringType: reflectStringType,
types.TimestampType: reflect.TypeOf(time.Time{}),
types.UintType: reflect.TypeOf(uint64(0)),
Expand Down
2 changes: 2 additions & 0 deletions testdata/json_encode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cmp stdout want.txt

-- src.cel --
[
null.encode_json(),
{"a":1, "b":[1, 2, 3]}.encode_json(),
encode_json({"a":1, "b":[1, 2, 3]}),
({
Expand All @@ -25,6 +26,7 @@ cmp stdout want.txt
]
-- want.txt --
[
"null",
"{\"a\":1,\"b\":[1,2,3]}",
"{\"a\":1,\"b\":[1,2,3]}",
"{\"a\":{\"b\":{\"c\":1}}}",
Expand Down
Loading