File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717* Fixed Grasshopper ` draw_polylines ` method to return ` PolylineCurve ` instead of ` Polyline ` because the latter shows as only points.
1818* Fixed uninstall post-process.
1919* Fixed ` area_polygon ` that was, in some cases, returning a negative area
20+ * Fixed support for ` System.Decimal ` data type on json serialization.
2021
2122### Removed
2223
Original file line number Diff line number Diff line change 88
99from compas .data .exceptions import DecoderError
1010
11+ IDictionary = None
12+ numpy_support = False
13+ dotnet_support = False
14+
1115# We don't do this from `compas.IPY` to avoid circular imports
1216if "ironpython" == platform .python_implementation ().lower ():
17+ dotnet_support = True
18+
1319 try :
20+ import System
1421 from System .Collections .Generic import IDictionary
1522 except : # noqa: E722
16- IDictionary = None
17- else :
18- IDictionary = None
23+ pass
24+
25+ try :
26+ import numpy as np
27+
28+ numpy_support = True
29+ except ImportError :
30+ numpy_support = False
1931
2032
2133def cls_from_dtype (dtype ):
@@ -113,11 +125,7 @@ def default(self, o):
113125 if hasattr (o , "__next__" ):
114126 return list (o )
115127
116- try :
117- import numpy as np
118- except ImportError :
119- pass
120- else :
128+ if numpy_support :
121129 if isinstance (o , np .ndarray ):
122130 return o .tolist ()
123131 if isinstance (
@@ -144,6 +152,10 @@ def default(self, o):
144152 if isinstance (o , np .void ):
145153 return None
146154
155+ if dotnet_support :
156+ if isinstance (o , System .Decimal ):
157+ return float (o )
158+
147159 return super (DataEncoder , self ).default (o )
148160
149161
You can’t perform that action at this time.
0 commit comments