This project is read-only.
1

Closed

dynamic object to fast json -> fails

description

I have a issue when I try to serialize to JSON a dynamic object.
dynamic deserializedJSON_ = new ExpandoObject();
deserializedJSON_.UserView = "10080";
deserializedJSON_.UserCatalog ="test";
deserializedJSON_.UserDate = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
deserializedJSON_.UserBase = "";

string x=fastJSON.JSON.ToJSON(deserializedJSON_);

my x=[{},{},{},{}]
also the microsoft version fails:
string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(deserializedJSON_);
[{"Key":"UserView","Value":"10080"},{"Key":"UserCatalog","Value":6668},{"Key":"UserDate","Value":63560047397981},{"Key":"UserBase","Value":""}]
I need to use dynamic cause my object can change a lot ...so why can't fastJSON serialize a dynamic type?

Update: the error was reported for version 2.1.3; just updated to 2.1.9 and seems ExpandoObject is fully supported.

PS: thank you MGholam for your time
Closed Jul 15, 2016 at 10:47 AM by MGholam
Fixed in 2.1.17

comments

MGholam wrote Feb 20, 2015 at 4:56 PM

ExpandoObject is not currently supported.

You can easily do :
dynamic a = new {
UserView = "10080",
UserCatalog ="test"
...
};