File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ var JSONEncodeFunc = function.New(&function.Spec{
1212 Name : "val" ,
1313 Type : cty .DynamicPseudoType ,
1414 AllowDynamicType : true ,
15+ AllowNull : true ,
1516 },
1617 },
1718 Type : function .StaticReturnType (cty .String ),
@@ -24,6 +25,10 @@ var JSONEncodeFunc = function.New(&function.Spec{
2425 return cty .UnknownVal (retType ), nil
2526 }
2627
28+ if val .IsNull () {
29+ return cty .StringVal ("null" ), nil
30+ }
31+
2732 buf , err := json .Marshal (val , val .Type ())
2833 if err != nil {
2934 return cty .NilVal , err
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ func TestJSONEncode(t *testing.T) {
5252 cty .DynamicVal ,
5353 cty .UnknownVal (cty .String ),
5454 },
55+ {
56+ cty .NullVal (cty .String ),
57+ cty .StringVal ("null" ),
58+ },
5559 }
5660
5761 for _ , test := range tests {
You can’t perform that action at this time.
0 commit comments