BimJsonUtil.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:BimJsonUtil
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/18 11:23:16
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using JBIM;
  13. using Newtonsoft.Json;
  14. namespace RevitToJBim.JsonConverter
  15. {
  16. public static class BimJsonUtil
  17. {
  18. public static string Serializer(BimDocument document)
  19. {
  20. JsonSerializerSettings jsetting = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
  21. jsetting.Converters.Add(new BimIdConverter());
  22. //var serializer = JsonSerializer.Create(jsetting);
  23. //JObject jobject = new JObject();
  24. //foreach (var collection in m_DataSource)
  25. //{
  26. // jobject.Add(collection.Key, JArray.FromObject(collection.Value, serializer));
  27. //}
  28. //var settings = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
  29. string dataStr = JsonConvert.SerializeObject(document.BimObjects, jsetting);
  30. return dataStr;
  31. }
  32. }
  33. }