示例#1
0
        public void WriteArrayProperty(string propertyName, IEnumerable items)
        {
            if (items != null)
            {
                List <object> itemList = new List <object>();

                foreach (var item in items)
                {
                    if (TypeUtil.IsKnownType(item.GetType()))
                    {
                        var writer = new DictionaryJsonWriter();
                        JsonSerializer.Write(item, writer);
                        itemList.Add(writer.ToDictionary());
                    }
                    else if (item is Enum)
                    {
                        itemList.Add(item.ToString().ToCamelCase());
                    }
                    else
                    {
                        itemList.Add(item);
                    }
                }

                _jsonDictionary.Add(propertyName, itemList);
            }
            else if (_writeDefaultValues)
            {
                _jsonDictionary.Add(propertyName, items);
            }
        }
示例#2
0
        public void WriteArrayProperty(string propertyName, IEnumerable items)
        {
            if (items != null)
            {
                List<object> itemList = new List<object>();
                
                foreach (var item in items)
                {                    
                    if (TypeUtil.IsKnownType(item.GetType()))
                    {                        
                        var writer = new DictionaryJsonWriter();
                        JsonSerializer.Write(item, writer);
                        itemList.Add(writer.ToDictionary());
                    }
                    else if (item is Enum)
                    {
                        itemList.Add(item.ToString().ToCamelCase());
                    }
                    else
                    {
                        itemList.Add(item);
                    }
                }

                _jsonDictionary.Add(propertyName, itemList);
            }
            else if (_writeDefaultValues)
            {
                _jsonDictionary.Add(propertyName, items);
            }
        }
示例#3
0
        private void WriteJsonProperty(string propertyName, object json)
        {
            var writer = new DictionaryJsonWriter();

            JsonSerializer.Write(json, writer);
            _jsonDictionary.Add(propertyName, writer.ToDictionary());
        }
示例#4
0
 private void WriteJsonProperty(string propertyName, object json)
 {
     var writer = new DictionaryJsonWriter();
     JsonSerializer.Write(json, writer);
     _jsonDictionary.Add(propertyName, writer.ToDictionary());
 }