77using Google . Protobuf ;
88using Google . Protobuf . Reflection ;
99using Google . Protobuf . WellKnownTypes ;
10- using Weaviate . Client . Models ;
1110using Weaviate . Client . Serialization ;
1211
1312namespace Weaviate . Client ;
@@ -22,37 +21,35 @@ internal class ObjectHelper
2221 }
2322
2423 var element = e . Value ;
25-
2624 if ( element . ValueKind == JsonValueKind . Object )
2725 {
2826 var expando = new ExpandoObject ( ) ;
29- var dictionary = ( IDictionary < string , object ? > ) expando ;
30-
31- foreach ( var property in element . EnumerateObject ( ) )
27+ var dict = ( IDictionary < string , object ? > ) expando ;
28+ foreach ( var prop in element . EnumerateObject ( ) )
3229 {
33- dictionary [ property . Name ] = ConvertJsonElement ( property . Value ) ;
30+ dict [ prop . Name ] = ConvertJsonElement ( prop . Value ) ;
3431 }
35-
3632 return expando ;
3733 }
38-
3934 if ( element . ValueKind == JsonValueKind . Array )
4035 {
41- return element
42- . EnumerateArray ( )
43- . OfType < JsonElement ? > ( )
44- . Select ( ConvertJsonElement )
45- . ToArray ( ) ;
36+ var list = new List < object ? > ( ) ;
37+ foreach ( var item in element . EnumerateArray ( ) )
38+ {
39+ list . Add ( ConvertJsonElement ( item ) ) ;
40+ }
41+ return list ;
4642 }
47-
4843 return element . ValueKind switch
4944 {
5045 JsonValueKind . String => element . GetString ( ) ,
51- JsonValueKind . Number => element . TryGetInt32 ( out int i ) ? i : element . GetDouble ( ) ,
46+ JsonValueKind . Number => element . TryGetInt64 ( out var l ) ? l
47+ : element . TryGetDouble ( out var d ) ? d
48+ : element . GetDecimal ( ) ,
5249 JsonValueKind . True => true ,
5350 JsonValueKind . False => false ,
54- JsonValueKind . Null => null ,
55- _ => element . ToString ( ) ,
51+ JsonValueKind . Null or JsonValueKind . Undefined => null ,
52+ _ => element . GetRawText ( ) ,
5653 } ;
5754 }
5855
0 commit comments