Skip to content
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
2 changes: 1 addition & 1 deletion lib/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func encodeJSON(val ref.Val) ref.Val {
switch under := val.Value().(type) {
case map[string]any:
v = under
case map[ref.Val]ref.Val:
case map[ref.Val]ref.Val, []ref.Val:
pb, err := val.ConvertToNative(structpbValueType)
if err != nil {
return types.NewErr("failed proto conversion: %v", err)
Expand Down
4 changes: 3 additions & 1 deletion testdata/json_encode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cmp stdout want.txt
}),
"plain text".encode_json(),
encode_json("plain text"),
[0, 1].map(i, {"a":i}).encode_json()
]
-- want.txt --
[
Expand All @@ -32,5 +33,6 @@ cmp stdout want.txt
"{\"a\":{\"b\":{\"c\":1}}}",
"{\"a\":{\"b\":{\"c\":1}}}",
"\"plain text\"",
"\"plain text\""
"\"plain text\"",
"[{\"a\":0},{\"a\":1}]"
]
Loading