How can we help you today? How can we help you today?

When running JsonConvert.SerializeObject on an object {} is returned

I have obfuscated an assembly with Smart Assembly and when calling:

string json = JsonConvert.SerializeObject(drivers);

json ends up as "[{}]"

If I add [Serializable] to the class I end up with:
[{"dsh":[{},{},{},{}],"ds":[]},{"dsh":[{},{},{},{},{},{},{},{},{},{},{},{},{},{}],"ds":[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]}]

But still no values.

If I don't obfuscate the code then the json string is created correctly with the correct values.

What do I need to use to get the JsonConvert.SerializeObject(drivers); to correctly serialize?

I have added:
[Serializable SmartAssembly.Attributes.DoNotObfuscate SmartAssembly.Attributes.DoNotPrune SmartAssembly.Attributes.DoNotObfuscateType]

to the classes used in the drivers object without any success. 

shane_russo
0

Comments

1 comment

  • shane_russo
    Turns out that adding:

    [Serializable SmartAssembly.Attributes.DoNotPruneType]

    to the class fixes the problem.

    (Keep in mind that you have to reference the SmartAssembly.Attributes.dll in your project before you can add the command to your class)
    shane_russo
    0

Add comment

Please sign in to leave a comment.