1414using Microsoft . Azure . WebJobs . Script . Description ;
1515using Microsoft . Azure . WebJobs . Script . Extensibility ;
1616using Newtonsoft . Json ;
17- using Newtonsoft . Json . Converters ;
1817using Newtonsoft . Json . Linq ;
1918
2019namespace Microsoft . Azure . WebJobs . Script . Binding
2120{
2221 public abstract class FunctionBinding
2322 {
2423 private readonly ScriptHostConfiguration _config ;
25- private static readonly ExpandoObjectConverter _expandoObjectJsonConverter = new ExpandoObjectConverter ( ) ;
2624
2725 protected FunctionBinding ( ScriptHostConfiguration config , BindingMetadata metadata , FileAccess access )
2826 {
@@ -168,7 +166,7 @@ internal static async Task BindAsyncCollectorAsync<T>(BindingContext context)
168166 {
169167 if ( value is ExpandoObject )
170168 {
171- converted = ToJson ( ( ExpandoObject ) value ) ;
169+ converted = Utility . ToJson ( ( ExpandoObject ) value , Formatting . None ) ;
172170 }
173171 else
174172 {
@@ -183,7 +181,7 @@ internal static async Task BindAsyncCollectorAsync<T>(BindingContext context)
183181 }
184182 else if ( value is ExpandoObject )
185183 {
186- converted = ToJObject ( ( ExpandoObject ) value ) ;
184+ converted = Utility . ToJObject ( ( ExpandoObject ) value ) ;
187185 }
188186 }
189187 else if ( typeof ( T ) == typeof ( byte [ ] ) )
@@ -194,7 +192,7 @@ internal static async Task BindAsyncCollectorAsync<T>(BindingContext context)
194192 string stringValue = null ;
195193 if ( value is ExpandoObject )
196194 {
197- stringValue = ToJson ( ( ExpandoObject ) value ) ;
195+ stringValue = Utility . ToJson ( ( ExpandoObject ) value , Formatting . None ) ;
198196 }
199197 else
200198 {
@@ -283,7 +281,7 @@ public static void ConvertValueToStream(object value, Stream stream)
283281 }
284282 else if ( value is ExpandoObject )
285283 {
286- string json = ToJson ( ( ExpandoObject ) value ) ;
284+ string json = Utility . ToJson ( ( ExpandoObject ) value , Formatting . None ) ;
287285 bytes = Encoding . UTF8 . GetBytes ( json ) ;
288286 }
289287
@@ -327,16 +325,5 @@ public static void ConvertStreamToValue(Stream stream, DataType dataType, ref ob
327325 break ;
328326 }
329327 }
330-
331- internal static string ToJson ( ExpandoObject value )
332- {
333- return JsonConvert . SerializeObject ( value , Formatting . None , _expandoObjectJsonConverter ) ;
334- }
335-
336- internal static JObject ToJObject ( ExpandoObject value )
337- {
338- string json = ToJson ( value ) ;
339- return JObject . Parse ( json ) ;
340- }
341328 }
342329}
0 commit comments