This project has moved and is read-only. For the latest updates, please go here.

Deserializing Public Properties w/ Private / Protected Set No Longer Works

Aug 7, 2010 at 12:19 AM
In Release 7 you used to be able to serialize / deserialize public properties with a non public setter. As of the latest revision, you can still serialize these members, but *De*serializing them doesn't work. Was this intentional? Should I create an issue? I really would like to leverage the TypeMemberHandling.Auto functionality but for now I will have to revert...
Aug 7, 2010 at 12:33 AM
Belay that... it might have been a release older than 7. I am not sure because I usually get the binaries from another OSS.
Aug 7, 2010 at 5:08 AM
Edited Aug 9, 2010 at 2:19 AM

Json.NET now only serializes/deserializes public properties and fields by default. Internal, protected and private members need to be marked with [JsonProperty] to be serialized and deserialized.

If you don't want to add attributes to your objects then another option is to set DefaultMemberSearchFlags on DefaultContractResolver and pass that to JsonConvert/JsonSerializer.