14
14
using Microsoft . Azure . WebJobs . Script . Description ;
15
15
using Microsoft . Azure . WebJobs . Script . Extensibility ;
16
16
using Newtonsoft . Json ;
17
- using Newtonsoft . Json . Converters ;
18
17
using Newtonsoft . Json . Linq ;
19
18
20
19
namespace Microsoft . Azure . WebJobs . Script . Binding
21
20
{
22
21
public abstract class FunctionBinding
23
22
{
24
23
private readonly ScriptHostConfiguration _config ;
25
- private static readonly ExpandoObjectConverter _expandoObjectJsonConverter = new ExpandoObjectConverter ( ) ;
26
24
27
25
protected FunctionBinding ( ScriptHostConfiguration config , BindingMetadata metadata , FileAccess access )
28
26
{
@@ -168,7 +166,7 @@ internal static async Task BindAsyncCollectorAsync<T>(BindingContext context)
168
166
{
169
167
if ( value is ExpandoObject )
170
168
{
171
- converted = ToJson ( ( ExpandoObject ) value ) ;
169
+ converted = Utility . ToJson ( ( ExpandoObject ) value , Formatting . None ) ;
172
170
}
173
171
else
174
172
{
@@ -183,7 +181,7 @@ internal static async Task BindAsyncCollectorAsync<T>(BindingContext context)
183
181
}
184
182
else if ( value is ExpandoObject )
185
183
{
186
- converted = ToJObject ( ( ExpandoObject ) value ) ;
184
+ converted = Utility . ToJObject ( ( ExpandoObject ) value ) ;
187
185
}
188
186
}
189
187
else if ( typeof ( T ) == typeof ( byte [ ] ) )
@@ -194,7 +192,7 @@ internal static async Task BindAsyncCollectorAsync<T>(BindingContext context)
194
192
string stringValue = null ;
195
193
if ( value is ExpandoObject )
196
194
{
197
- stringValue = ToJson ( ( ExpandoObject ) value ) ;
195
+ stringValue = Utility . ToJson ( ( ExpandoObject ) value , Formatting . None ) ;
198
196
}
199
197
else
200
198
{
@@ -283,7 +281,7 @@ public static void ConvertValueToStream(object value, Stream stream)
283
281
}
284
282
else if ( value is ExpandoObject )
285
283
{
286
- string json = ToJson ( ( ExpandoObject ) value ) ;
284
+ string json = Utility . ToJson ( ( ExpandoObject ) value , Formatting . None ) ;
287
285
bytes = Encoding . UTF8 . GetBytes ( json ) ;
288
286
}
289
287
@@ -327,16 +325,5 @@ public static void ConvertStreamToValue(Stream stream, DataType dataType, ref ob
327
325
break ;
328
326
}
329
327
}
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
- }
341
328
}
342
329
}
0 commit comments