@@ -144,7 +144,7 @@ private async Task ProcessInputBindingsAsync(IBinderEx binder, Dictionary<string
144
144
var nonTriggerInputBindings = _inputBindings . Where ( p => ! p . Metadata . IsTrigger ) ;
145
145
foreach ( var inputBinding in nonTriggerInputBindings )
146
146
{
147
- string value = null ;
147
+ string stringValue = null ;
148
148
using ( MemoryStream stream = new MemoryStream ( ) )
149
149
{
150
150
BindingContext bindingContext = new BindingContext
@@ -157,12 +157,15 @@ private async Task ProcessInputBindingsAsync(IBinderEx binder, Dictionary<string
157
157
158
158
stream . Seek ( 0 , SeekOrigin . Begin ) ;
159
159
StreamReader sr = new StreamReader ( stream ) ;
160
- value = sr . ReadToEnd ( ) ;
160
+ stringValue = sr . ReadToEnd ( ) ;
161
161
}
162
162
163
- bindings . Add ( inputBinding . Metadata . Name , value ) ;
163
+ // if the string input is json, convert to an object
164
+ object convertedValue = stringValue ;
165
+ convertedValue = TryConvertJsonToObject ( stringValue ) ;
164
166
165
- inputs . Add ( value ) ;
167
+ bindings . Add ( inputBinding . Metadata . Name , convertedValue ) ;
168
+ inputs . Add ( convertedValue ) ;
166
169
}
167
170
168
171
executionContext [ "inputs" ] = inputs ;
@@ -280,12 +283,8 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
280
283
Type triggerParameterType = input . GetType ( ) ;
281
284
if ( triggerParameterType == typeof ( string ) )
282
285
{
283
- // if the input is json, convert to a json object
284
- Dictionary < string , object > jsonObject ;
285
- if ( TryDeserializeJsonObject ( ( string ) input , out jsonObject ) )
286
- {
287
- input = jsonObject ;
288
- }
286
+ // if the input is json, convert to an object
287
+ input = TryConvertJsonToObject ( ( string ) input ) ;
289
288
}
290
289
else if ( triggerParameterType == typeof ( HttpRequestMessage ) )
291
290
{
@@ -335,6 +334,20 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
335
334
return context ;
336
335
}
337
336
337
+ private object TryConvertJsonToObject ( string input )
338
+ {
339
+ object result = input ;
340
+
341
+ // if the input is json, convert to an object
342
+ Dictionary < string , object > jsonObject ;
343
+ if ( TryDeserializeJsonObject ( input , out jsonObject ) )
344
+ {
345
+ result = jsonObject ;
346
+ }
347
+
348
+ return result ;
349
+ }
350
+
338
351
private Dictionary < string , object > CreateRequestObject ( HttpRequestMessage request )
339
352
{
340
353
// TODO: need to provide access to remaining request properties
0 commit comments