RickStrahl / Expando

Extensible dynamic types for .NET
108 stars 30 forks source link

Unity support #16

Closed mediumTaj closed 4 years ago

mediumTaj commented 5 years ago

I'm trying to use your project in Unity 3D (added dll to the Unity project). It works for the most part but the TwoWayJsonSerializeExpandoTyped test results in

{
  "Properties": {
    "Entered": "2019-02-28T14:38:38.3122796-06:00",
    "Company": "West Wind",
    "Accesses": 10,
    "Address": "32 Kaiea",
    "TotalOrderAmounts": 51233.99
  },
  "email": "rick@west-wind.com",
  "password": "Seekrit23",
  "name": "Rick",
  "active": true
}

I tried the same test directly from Expando and get the expected result

{
  "Email": "rick@west-wind.com",
  "Password": "Seekrit23",
  "Name": "Rick",
  "Active": true,
  "ExpiresOn": null,
  "Entered": "2019-02-28T14:53:19.3184712-06:00",
  "Company": "West Wind",
  "Accesses": 10,
  "Address": "32 Kaiea",
  "TotalOrderAmounts": 51233.99
}

Any ideas why they would have different results?

RickStrahl commented 4 years ago

The custom serialization only works with the Netwonsoft.Json serializer. If another serializer is used you get the raw class interface which includes the properties collection which is what you see in your code. You'll have to create a custom serialization mapper for whatever serializer you're using.