B
Billy Zhang
I have a asp.net app, in client I create a Complicate json string,
for example: { a: ‘a’, b : { b ; ‘b’ } }
If .net has corresponding type, it could be
deserialized, for example:
DataContractJsonSerializer serializer = new
DataContractJsonSerializer(typeof(A));
using (MemoryStream ms = new
MemoryStream(Encoding.Unicode.GetBytes(jsonText))) {
//serializer.WriteObject(ms);
//return Encoding.Default.GetString(ms.ToArray());
A a = (A)serializer.ReadObject(ms);
return a;
}
But the question is if there are no corresponding .net type, in .net 3.5
could we serialize it into anonymous type? Or any other way to solve this
problem?
-Billy zhang
for example: { a: ‘a’, b : { b ; ‘b’ } }
If .net has corresponding type, it could be
deserialized, for example:
DataContractJsonSerializer serializer = new
DataContractJsonSerializer(typeof(A));
using (MemoryStream ms = new
MemoryStream(Encoding.Unicode.GetBytes(jsonText))) {
//serializer.WriteObject(ms);
//return Encoding.Default.GetString(ms.ToArray());
A a = (A)serializer.ReadObject(ms);
return a;
}
But the question is if there are no corresponding .net type, in .net 3.5
could we serialize it into anonymous type? Or any other way to solve this
problem?
-Billy zhang