1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System.Collections.Generic;
- using Tea;
- using Newtonsoft.Json;
- namespace Alipay.EasySDK.Kernel.Util
- {
-
-
-
- public class JsonUtil
- {
-
-
-
-
-
- public static string ToJsonString(IDictionary<string, object> input)
- {
- IDictionary<string, object> result = new Dictionary<string, object>();
- foreach (var pair in input)
- {
- if (pair.Value is TeaModel)
- {
- result.Add(pair.Key, GetTeaModelMap((TeaModel)pair.Value));
- }
- else
- {
- result.Add(pair.Key, pair.Value);
- }
- }
- return JsonConvert.SerializeObject(result);
- }
- private static IDictionary<string, object> GetTeaModelMap(TeaModel teaModel)
- {
- IDictionary<string, object> result = new Dictionary<string, object>();
- IDictionary<string, object> teaModelMap = teaModel.ToMap();
- foreach (var pair in teaModelMap)
- {
- if (pair.Value is TeaModel)
- {
- result.Add(pair.Key, GetTeaModelMap((TeaModel)pair.Value));
- }
- else
- {
- result.Add(pair.Key, pair.Value);
- }
- }
- return result;
- }
- }
- }
|