@@ -144,7 +144,7 @@ private async Task ProcessInputBindingsAsync(IBinderEx binder, Dictionary<string
144144 var nonTriggerInputBindings = _inputBindings . Where ( p => ! p . Metadata . IsTrigger ) ;
145145 foreach ( var inputBinding in nonTriggerInputBindings )
146146 {
147- string value = null ;
147+ string stringValue = null ;
148148 using ( MemoryStream stream = new MemoryStream ( ) )
149149 {
150150 BindingContext bindingContext = new BindingContext
@@ -157,12 +157,15 @@ private async Task ProcessInputBindingsAsync(IBinderEx binder, Dictionary<string
157157
158158 stream . Seek ( 0 , SeekOrigin . Begin ) ;
159159 StreamReader sr = new StreamReader ( stream ) ;
160- value = sr . ReadToEnd ( ) ;
160+ stringValue = sr . ReadToEnd ( ) ;
161161 }
162162
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 ) ;
164166
165- inputs . Add ( value ) ;
167+ bindings . Add ( inputBinding . Metadata . Name , convertedValue ) ;
168+ inputs . Add ( convertedValue ) ;
166169 }
167170
168171 executionContext [ "inputs" ] = inputs ;
@@ -280,12 +283,8 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
280283 Type triggerParameterType = input . GetType ( ) ;
281284 if ( triggerParameterType == typeof ( string ) )
282285 {
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 ) ;
289288 }
290289 else if ( triggerParameterType == typeof ( HttpRequestMessage ) )
291290 {
@@ -335,6 +334,20 @@ private Dictionary<string, object> CreateScriptExecutionContext(object input, Tr
335334 return context ;
336335 }
337336
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+
338351 private Dictionary < string , object > CreateRequestObject ( HttpRequestMessage request )
339352 {
340353 // TODO: need to provide access to remaining request properties
0 commit comments